home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / YobGame / source / yob123fa4ab.s < prev    next >
Encoding:
Text File  |  1991-05-18  |  147.0 KB  |  7,670 lines

  1. V123
  2. ;Fixed it to work on any amiga (whatever screen mode [not pal/ntsc]!!!!)
  3. ;Fixed sprite problems on return to WB
  4.  
  5. ;YOBTRIS -=> see history
  6.  
  7. ;big marble at top of screen rolls down. Try and get it in the hole
  8. ;marble bounces!
  9.  
  10. ;drawn new fuck off weapon for baddies n player.(above^)
  11. ;big beam (full width screen) destorys ANYTHING on contact (inc pforms)
  12.  
  13. ;Layzee Beam..
  14. ;4words wide (use baddy bullets) and goes up the entire screen!
  15. ;freezes players and baddies for a few seconds
  16.  
  17. debugging    equ    0    ;no copper (using monam)
  18. slowly    equ    1    ;do everything (slow lmb)
  19.  
  20.     section screen,code_c        ;make sure chip ram
  21.     
  22.  
  23.  
  24.  
  25.     include    iconstartup2.i
  26.  
  27.     bra    YOBBING
  28.     
  29. showCOLL    dc.b    0    ;show only the collision copperlist
  30.     dc.b    "$VER:Yobbin 123fa4a"
  31.     cnop    0,4
  32. YOBBING
  33.  
  34.     opt    c+
  35. bullgfxline    equ    5    ;how many bullet gfx lines (for iff conv)
  36. yobtitnum    equ    24    ;how many yob title bars!
  37.  
  38. _CUSTOM    equ    $dff000    
  39. scrwid    equ    42
  40. scrhi    equ    19    ;1+16+2
  41. screensize    equ    scrwid*(scrhi*16)*5
  42. collsize    equ    scrwid*(scrhi*16)
  43. level_wid    equ    20
  44. level_hi    equ    16
  45. players_max    equ    2    ;max no. players
  46.  
  47. baddygfx    equ    5    ;no baddies in iff file
  48. bad_max    equ    6    ;max no. of baddies
  49. bullet_max    equ    2    ;max no. baddy bullets
  50. gun_max    equ    2*players_max    ;no. bullets per player
  51.  
  52. bnb_max    equ    8    ;* MAKE ME THE MAX OF BADDIES AND BULLETS * used in play to baddy/bull collision
  53.  
  54. gravity    equ    40    ;max pos in fall table
  55. HitPoints    equ    20    ;player hit points (BYTE)
  56. hittime    equ    20    ;how long is player hit for    
  57. pamax    equ    4    ;how many vblank between player anim update!
  58. SmartLife    equ    $200    ;how long the smart bullets lasts seeking!
  59.  
  60.     move.w    #$8400,$dff096
  61.  
  62.     lea    gfxname,a1
  63.     CALLEXEC    OldOpenLibrary
  64.     beq    NO_MEMORY
  65.     move.l    d0,_GfxBase
  66.  
  67.     lea    iffname,a1
  68.     CALLEXEC    OldOpenLibrary
  69.     beq    NO_MEMORY
  70.     move.l    d0,_IFFBase
  71.  
  72.     lea    dosname,a1
  73.     CALLEXEC    OldOpenLibrary
  74.     beq    NO_MEMORY
  75.     move.l    d0,_DOSBase
  76.  
  77.  
  78.  
  79.     lea    intname,a1          ;
  80.     moveq    #39,d0                  ; Kickstart 3.0 or higher
  81.     CALLEXEC    OpenLibrary
  82.     move.l    d0,_IntuitionBase       ; store intuitionbase
  83.  
  84.  
  85.     ifeq debugging
  86.  
  87.     
  88.     CALLGRAF    OwnBlitter
  89.     endc
  90.  
  91.     bsr    alloccollbase
  92.     cmp.l    #0,collbase
  93.     beq    NO_MEMORY
  94.  
  95.     bsr    allocscrbase
  96.     cmp.l    #0,scrbase
  97.     beq    NO_MEMORY    ;no memory
  98.     move.l    scrbase,screen1
  99.  
  100.     bsr    allocscrbase
  101.     cmp.l    #0,scrbase
  102.     beq    NO_MEMORY    ;no memory
  103.     move.l    scrbase,screen2
  104.  
  105.     move.b    #001,LevelNum        ;start at level 1
  106.  
  107.     bsr    LoadNProcess    ;load all gfx in and process
  108.     bsr    AllocTemps        ;alloc all the tempory storage for gfx
  109.     
  110.  
  111.     bsr    go_bitplanes
  112.     bsr    go_colour    
  113.     bsr    copycolour        ;copy it for the title screen
  114.  
  115.     bsr    get_old_cop
  116.  
  117.     bsr    init_bulls    
  118.     bsr    SetupALL
  119.     move.l    #bads_list,badcheck
  120.     move.b    #0,badcnt
  121.         
  122.     ifeq debugging
  123.  
  124.     move.l    _GfxBase,a6
  125.     move.l    gb_ActiView(a6),wbview  ; store current view address
  126.  
  127.     bsr    FixSpritesSetup         ; fix V39 sprite bug...
  128.  
  129.     move.l    _GfxBase,a6
  130. .skip    sub.l    a1,a1                   ; clear a1
  131.     CALLGRAF    LoadView        ; Flush View to nothing
  132.     CALLGRAF    WaitTOF         ; Wait once
  133.     CALLGRAF    WaitTOF         ; Wait again.
  134.  
  135.  
  136.  
  137.     ;^^^^^^^^ before anything
  138.  
  139.  
  140.         sub.l   a1,a1                   ; Zero - Find current task
  141.         CALLEXEC    FindTask
  142.  
  143.         move.l  d0,a1
  144.         moveq   #127,d0                 ; task priority to very high...
  145.         CALLEXEC    SetTaskPri
  146.         move.l    d0,oldpri
  147.  
  148.     move.w    #$0200,bitplanes    ;planes OFF
  149.     
  150.     bsr    vblank
  151.     bsr    vblank
  152.     move.l    #new,$dff080
  153.     endc
  154.  
  155.  
  156.     move.b    #0,TitleON        ;go straight into title screen!
  157.     move.b    #0,TitleONFT    ;make first timer
  158.             
  159.  
  160. main:
  161.     ifeq debugging
  162.     bsr    vblank2
  163.     
  164.     endc
  165.  
  166.     ifeq slowly
  167.     btst    #6,$bfe001
  168.     beq    over
  169.     bsr    vblank2
  170.     bsr    vblank2
  171.     bsr    vblank2
  172.     bsr    vblank2
  173.     bsr    vblank2
  174.     bsr    vblank2
  175.     bsr    vblank2
  176.     bsr    vblank2
  177.     bsr    vblank2
  178.     bsr    vblank2
  179.     bsr    vblank2
  180.     bsr    vblank2
  181.     bsr    vblank2
  182.     bsr    vblank2
  183.     bsr    vblank2
  184. over
  185.     endc
  186.  
  187.     cmp.b    #1,TitleON
  188.     bne    .notitle
  189.     bsr    title_code
  190.     bra    .mainreturn
  191. .notitle
  192.  
  193.         
  194.     bsr    go_bitplanes
  195.  
  196.     bsr    go_switch
  197.  
  198.     move.l    #0,d7
  199. .loop
  200.     add.l    #1,d7
  201.     cmp.l    #$1500,d7
  202. ;    bne    .loop
  203.  
  204.     bsr    go_flash        ;flash the screen (white to black)
  205.     
  206.     bsr    go_restorebullets
  207.     bsr    go_restoreplayer1
  208.     bsr    go_restorebads
  209.     bsr    go_restoreguns
  210.  
  211.     bsr    go_movebads
  212.     bsr    go_moveplayer1
  213.     bsr    go_moveguns
  214.     PUSHALL
  215.     bsr    go_movebullets
  216.     PULLALL
  217.  
  218.     bsr    go_printlazer
  219.     bsr    go_lazerzone
  220.  
  221.     bsr    go_grabguns
  222.     bsr    go_grabbads
  223.     bsr    go_grabplayer1
  224.     bsr    go_grabbullets
  225.  
  226.  
  227.      bsr    go_printguns
  228.     bsr    go_printbads
  229.     bsr    go_printplayer1
  230.     bsr    go_printbullets
  231.  
  232.  
  233.     bsr    go_collision
  234.     
  235.     add.b    #1,random
  236.  
  237.     bsr    randplayer
  238.  
  239. ;    move.w    #$fff,$dff180
  240.     nop
  241.     nop
  242.     nop
  243.     nop
  244.     nop
  245. ;    move.w    #$0,$dff180
  246.  
  247.     move.l    badcheck,a0
  248.     cmp.b    #DEAD,bad_status(a0)
  249.     bne    .notdead
  250.     
  251.     add.l    #(bad_type1_nd-bad_type1),badcheck    ;next struct
  252.     add.b    #1,badcnt
  253.     clr.l    d0
  254.     move.b    badcnt,d0
  255.     cmp.b    #bad_max-1,d0
  256.     bne    .deadcheck
  257.     ;hes done the level!
  258.     bsr    NewLevel
  259.     
  260.     
  261.     
  262. .notdead
  263.     move.l    #bads_list,badcheck
  264.     move.b    #0,badcnt
  265. .deadcheck
  266.     
  267.     
  268.     ;swap display collision or normal!
  269.     cmp.b    #$4f,$bfec01    ;COLL F9
  270.     bne    .notCOLL
  271.     move.b    #1,showCOLL
  272. .notCOLL
  273.     cmp.b    #$4d,$bfec01    ;NORM F10
  274.     bne    .notNORM
  275.     move.b    #0,showCOLL
  276. .notNORM
  277.     cmp.b    #$5f,$bfec01    ;F1 Next Lev
  278.     bne    .noNlev
  279.     
  280.     move.b    #1,TitleON        ;go straight into title screen!
  281. ;    bsr    NewLevel
  282. ;    move.w    $dff006,d0
  283. ;    and.l    #$fff,d0
  284. ;    move.w    d0,$dff180
  285.     
  286. .noNlev
  287.  
  288. .mainreturn
  289.     cmp.b    #$3f,$bfec01
  290.     bne    main
  291.     
  292. exit    move    #%1000000000100000,$dff096;enable sprites
  293.     
  294.     ifeq debugging    
  295.     move.l    old,$dff080    
  296.     endc
  297.  
  298.     ;free up intset memory
  299.     move.l    IntSize,d0
  300.     move.l    IntBase,a1
  301.     CALLEXEC    FreeMem
  302.  
  303.     bsr    FreeTemps
  304.     bsr    FreeGfxMem
  305.  
  306.     bsr    freecollbase        
  307.     move.l    screen1,scrbase
  308.     bsr    freescrbase
  309.     move.l    screen2,scrbase
  310.     bsr    freescrbase
  311.  
  312. NO_MEMORY
  313.     ifeq debugging    
  314.     CALLGRAF    DisownBlitter
  315.     endc
  316.  
  317.     sub.l    a1,a1                   ; Zero - Find current task
  318.     CALLEXEC    FindTask
  319.  
  320.     move.l    d0,a1
  321.     move.l    oldpri,d0                 ; task priority to very low...
  322.     CALLEXEC    SetTaskPri
  323.  
  324.     ;VVVVVVVV after everything
  325.  
  326.  
  327.     bsr    ReturnSpritesToNormal
  328.  
  329.     move.l    wbview,a1
  330.     move.l    _GfxBase,a6
  331.     CALLGRAF    LoadView        ; Fix view
  332.     CALLGRAF    WaitTOF
  333.     CALLGRAF    WaitTOF         ; wait for LoadView()
  334.  
  335.     move.l    gb_copinit(a6),$dff080.L  ; Kick it into life
  336.  
  337.     CALLINT    RethinkDisplay     ; and rethink....
  338.  
  339.  
  340.     bsr    CloseLibs
  341. FEXIT    clr.l    d0
  342.     rts
  343.  
  344.     include    initial.inc    ;vblank,vblank2,go_colour,allocscrbase,freescrbase,get_old_cop
  345.  
  346. go_switch    
  347.     bchg    #1,switch
  348.     bne    .over
  349.     move.l    screen1,scrbase
  350.     bra    .skip
  351. .over
  352.     move.l    screen2,scrbase
  353. .skip
  354.     rts
  355.  
  356. CloseLibs
  357.     move.l    _GfxBase,a1
  358.     cmp.l    #0,a1
  359.     beq    .hup
  360.     CALLEXEC    CloseLibrary
  361. .hup
  362.     move.l    _IFFBase,a1
  363.     cmp.l    #0,a1
  364.     beq    .hup2
  365.     CALLEXEC    CloseLibrary
  366. .hup2
  367.     move.l    _DOSBase,a1
  368.     cmp.l    #0,a1
  369.     beq    .hup3
  370.     CALLEXEC    CloseLibrary
  371. .hup3
  372.     move.l    _IntuitionBase,a1
  373.     cmp.l    #0,a1
  374.     beq    .hup4
  375.     CALLEXEC    CloseLibrary
  376. .hup4
  377.  
  378.     rts
  379. alloccollbase
  380.     move.l    #$10002,d1    ;memory Ill have chip please
  381.     move.l    #collsize,d0    ;this much please
  382.     CALLEXEC    AllocMem
  383.     move.l    d0,collbase
  384.     rts
  385. freecollbase
  386.     move.l    #collsize,d0
  387.     move.l    collbase,a1
  388.     CALLEXEC    FreeMem
  389.     rts
  390.  
  391. FixSpritesSetup:
  392.     lea    wbname,a0
  393.     CALLINT    LockPubScreen
  394.  
  395.     tst.l    d0                         ; Could I lock Workbench?
  396.     beq.s    .error                     ; if not, error
  397.     move.l    d0,wbscreen
  398.     move.l    d0,a0
  399.  
  400.     move.l    sc_ViewPort+vp_ColorMap(a0),a0
  401.     lea    taglist,a1
  402.     CALLGRAF    VideoControl       ;
  403.  
  404.     move.l    resolution,oldres          ; store old resolution
  405.  
  406.     move.l    #SPRITERESN_140NS,resolution
  407.     move.l    #VTAG_SPRITERESN_SET,taglist
  408.  
  409.     move.l    wbscreen,a0
  410.     move.l    sc_ViewPort+vp_ColorMap(a0),a0
  411.     lea    taglist,a1
  412.     CALLGRAF    VideoControl       ; set sprites to lores
  413.  
  414.     move.l    wbscreen,a0
  415.     CALLINT    MakeScreen
  416.     CALLINT    RethinkDisplay     ; and rebuild system copperlists
  417.  
  418. ; Sprites are now set back to 140ns in a system friendly manner!
  419.  
  420. .error
  421.         rts
  422.  
  423. ReturnSpritesToNormal:
  424. ; If you mess with sprite resolution you must return resolution
  425. ; back to workbench standard on return! This code will do that...
  426.  
  427.         move.l   wbscreen,d0
  428.         beq.s    .error
  429.         move.l   d0,a0
  430.  
  431.         move.l   oldres,resolution          ; change taglist
  432.         lea      taglist,a1
  433.         move.l   sc_ViewPort+vp_ColorMap(a0),a0
  434.     CALLGRAF    VideoControl       ; return sprites to normal.
  435.  
  436.         move.l   wbscreen,a0
  437.     CALLINT    MakeScreen         ; and rebuild screen
  438.  
  439.         move.l   wbscreen,a1
  440.         sub.l    a0,a0
  441.     CALLINT    UnlockPubScreen
  442.  
  443. .error
  444.         rts
  445.     
  446.  
  447.  
  448.  
  449.  
  450.     
  451. back_to_screen    ;blit background on screen
  452.     move.l    BackBase,a0
  453.     move.l    scrbase,a1
  454.     add.l    #(16*scrwid*5)+2,a1
  455.  
  456.     move.l    #256-1,d6        ;no. lines
  457. .lines
  458.  
  459.     move.l    #5-1,d5        ;no. bitplanes
  460. .bplanes
  461.     ;copy 1 bpl line
  462.     move.l    #40-1,d4    ;no. bytes per row
  463. .bplline
  464.     move.b    (a0)+,(a1)+
  465.     dbra    d4,.bplline
  466.     
  467.     add.l    #scrwid-40,a1
  468.     dbra    d5,.bplanes
  469.     
  470.     dbra    d6,.lines
  471.     rts
  472. ;    CALLGRAF    WaitBlit
  473.     
  474. ;    move.l    #$ffffffff,$dff044
  475. ;    move.w    #40-40,$dff064    ;mod A
  476. ;    move.w    #scrwid-40,$dff066    ;mod D
  477. ;    move.w    #$0,$dff042
  478. ;    move.w    #$09f0,$dff040
  479.  
  480. ;    move.l    BackBase,a0
  481. ;    move.l    scrbase,a1
  482. ;    add.l    #(16*scrwid*5)+2,a1
  483. ;    move.l    a0,$dff050    ;A
  484. ;    move.l    a1,$dff054    ;dst D    screen
  485. ;    move.w    #(128*5*64)+20,$dff058
  486.     
  487. ;    add.l    #128*5*40,a0    ;next block of back
  488. ;    add.l    #128*5*scrwid,a1    ;next block of screen
  489.  
  490. ;    CALLGRAF    WaitBlit
  491. ;    move.l    a0,$dff050    ;A
  492. ;    move.l    a1,$dff054    ;dst D    screen
  493. ;    move.w    #(128*5*64)+20,$dff058
  494.  
  495. ;    rts
  496. go_bitplanes
  497.     cmp.b    #0,showCOLL
  498.     bne    goCOLLbplanes
  499.  
  500.     move.w    #5-1,d7
  501.     move.l    screen1,d0
  502.     cmp.l    scrbase,d0
  503.     bne    .ok
  504.     move.l    screen2,d0
  505. .ok
  506.     add.l    #(16*scrwid*5)+2,d0
  507.     lea    bit1h,a0
  508. cloop
  509.     move.w    d0,4(a0)    ;bit1l
  510.     swap    d0
  511.     move.w    d0,(a0)    ;bit1h
  512.     swap    d0
  513.     add.l    #scrwid,d0    ;next bitplane
  514.     add.l    #8,a0    ;next copper pos.
  515.     dbra    d7,cloop
  516.     move.w    #(scrwid*5)-40,modeven    ;screen modulos
  517.     move.w    #(scrwid*5)-40,mododd
  518.     move.w    #$5200,bitplanes    ;make 5 bitplane please
  519.  
  520.     rts
  521.  
  522. goCOLLbplanes
  523.     move.l    collbase,d0
  524.     add.l    #(16*scrwid)+2,d0
  525.  
  526. ;    move.l    BaddyCOLLBase,d0
  527.     lea    bit1h,a0
  528.     move.w    d0,4(a0)    ;bit1l
  529.     swap    d0
  530.     move.w    d0,(a0)    ;bit1h
  531.     move.w    #scrwid-40,modeven    ;screen modulos
  532.     move.w    #scrwid-40,mododd
  533.     move.w    #$1200,bitplanes    ;make 1 bitplane please
  534.     rts
  535.  
  536. init_bitplanes2
  537.     ;init the YOB title piccy!
  538.     lea    yobclist,a0        ;yob clist
  539.     move.l    #yobtitnum-1,d7        ;no. lines to do!
  540.     move.l    screen1,d0
  541.     add.l    #2,d0
  542.     move.l    #$0d09fffe,d1    ;copper line
  543. .yoloop
  544.     move.l    d1,(a0)+        ;copy copper line
  545.     move.w    #bplcon0,(a0)+        ;bplcon0
  546.     move.w    #$0200,(a0)+
  547.  
  548.     move.w    #bpl1h,(a0)+
  549.     move.w    #0,(a0)+
  550.     move.w    #bpl1l,(a0)+
  551.     move.w    #0,(a0)+
  552.  
  553.     move.w    #bpl2h,(a0)+
  554.     move.w    #0,(a0)+
  555.     move.w    #bpl2l,(a0)+
  556.     move.w    #0,(a0)+
  557.  
  558.     move.w    #bpl3h,(a0)+
  559.     move.w    #0,(a0)+
  560.     move.w    #bpl3l,(a0)+
  561.     move.w    #0,(a0)+
  562.  
  563.     move.w    #bpl4h,(a0)+
  564.     move.w    #0,(a0)+
  565.     move.w    #bpl4l,(a0)+
  566.     move.w    #0,(a0)+
  567.  
  568.     move.w    #bpl5h,(a0)+
  569.     move.w    #0,(a0)+
  570.     move.w    #bpl5l,(a0)+
  571.     move.w    #0,(a0)+
  572.  
  573.  
  574.     add.l    #$01000000,d1
  575.     dbra    d7,.yoloop
  576.     
  577.     ;init the press fire to start copper list
  578.     lea    pfts,a0        ;press fire to start (clist)
  579.     move.l    #40-1,d7        ;no. lines to do
  580.     move.l    screen1,d0        
  581.     add.l    #114*scrwid*5,d0    ;press fire
  582. ;    add.l    #162*scrwid*5,d0    ;to start
  583.     move.l    #$0109fffe,d1
  584. .pfloop
  585.     move.l    d1,(a0)+        ;copy copper line
  586.     move.l    d0,d2
  587.     move.w    #bpl1h,(a0)+
  588.     swap    d0
  589.     move.w    d0,(a0)+
  590.     move.w    #bpl1l,(a0)+
  591.     swap    d0
  592.     move.w    d0,(a0)+
  593.     
  594.     add.l    #scrwid,d0
  595.     move.w    #bpl2h,(a0)+
  596.     swap    d0
  597.     move.w    d0,(a0)+
  598.     move.w    #bpl2l,(a0)+
  599.     swap    d0
  600.     move.w    d0,(a0)+
  601.     
  602.     add.l    #scrwid,d0
  603.     move.w    #bpl3h,(a0)+
  604.     swap    d0
  605.     move.w    d0,(a0)+
  606.     move.w    #bpl3l,(a0)+
  607.     swap    d0
  608.     move.w    d0,(a0)+
  609.     
  610.     add.l    #scrwid,d0
  611.     move.w    #bpl4h,(a0)+
  612.     swap    d0
  613.     move.w    d0,(a0)+
  614.     move.w    #bpl4l,(a0)+
  615.     swap    d0
  616.     move.w    d0,(a0)+
  617.     
  618.     add.l    #scrwid,d0
  619.     move.w    #bpl5h,(a0)+
  620.     swap    d0
  621.     move.w    d0,(a0)+
  622.     move.w    #bpl5l,(a0)+
  623.     swap    d0
  624.     move.w    d0,(a0)+
  625.  
  626.     add.l    #scrwid*5,d2
  627.     move.l    d2,d0
  628.     add.l    #$01000000,d1    
  629.     dbra    d7,.pfloop
  630.             
  631.     rts
  632.  
  633. go_pfts
  634.     ;line 114 is start of press fire
  635.     ;line 162 is start of  to start
  636.  
  637.     ;these 2 rtns will scroll the to start into the press fire
  638.     
  639.     cmp.b    #0,pftswait
  640.     beq    .ok
  641.     sub.b    #1,pftswait
  642.     bra    .out
  643. .ok
  644.     bsr    tophalf
  645.     bsr    bothalf
  646.     
  647. .out    rts
  648.  
  649. tophalf
  650.     clr.l    d0
  651.     clr.l    d1
  652.     move.b    inbaset,d0        ;the new words (to start first)
  653.     move.b    inpost,d1        ;the new place
  654.  
  655.     lea    pfts,a0
  656.     add.l    #20*(4+(5*(4+4)))+4,a0    ;+4 to skip line pointer!
  657.  
  658.     ;find starting pos    
  659.     move.l    #20,d7
  660.     sub.b    d1,d7
  661. .spos    
  662.     cmp.b    #0,d7
  663.     beq    .foundit
  664.     sub.l    #4+(5*(4+4)),a0
  665.     sub.l    #1,d7
  666.     bra    .spos
  667.  
  668. .foundit    
  669.     ;a0 has starting place in clist
  670.     move.l    screen1,a1
  671.     sub.l    #1,d0
  672. .ppos
  673.     add.l    #(5*scrwid),a1
  674.     dbra    d0,.ppos
  675.     
  676.     ;a1 has the piccy pos
  677.     
  678.     ;now copy in so many
  679.     move.l    a1,d0
  680.     move.l    #20,d7
  681.     sub.l    d1,d7        ;d7 has how many to copy
  682.  
  683.     move.l    a0,a2
  684.     move.l    d0,d2
  685.  
  686. .copy
  687.     move.l    a2,a0
  688.     move.l    d2,d0
  689.     
  690.     move.l    #5-1,d6
  691. .plan
  692.     move.w    d0,6(a0)    ;bit1l
  693.     swap    d0
  694.     move.w    d0,2(a0)    ;bit1h
  695.     swap    d0
  696.     
  697.     add.l    #8,a0    ;next cplane
  698.     add.l    #scrwid,d0    ;next bitplane
  699.     dbra    d6,.plan
  700.     
  701.     add    #4+(5*(4+4)),a2    ;next line
  702.     add.l    #5*scrwid,d2
  703.     dbra    d7,.copy
  704.     
  705.     ;okay now dec inpost
  706.     
  707.     sub.b    #1,inpost
  708.     cmp.b    #0,inpost
  709.     bne    .nodone
  710.     ;hes finished!
  711.     move.b    #100,pftswait
  712.     move.b    #20,inpost
  713.     cmp.b    #114,inbaset
  714.     beq    .go162
  715.     move.b    #114,inbaset
  716.     bra    .nodone
  717. .go162
  718.     move.b    #162,inbaset
  719.     
  720. .nodone
  721.  
  722.     rts
  723. bothalf
  724.     clr.l    d0
  725.     clr.l    d1
  726.     move.b    inbaseb,d0        ;the new words (to start first)
  727.     move.b    inposb,d1        ;the new place
  728.  
  729.     ;first find the end place in the copper list
  730.     lea    pfts,a0
  731.     add.l    #20*(4+(5*(4+4)))+4,a0    ;+4 to skip line pointer!
  732.     
  733.     move.l    #20,d7
  734.     sub.l    d1,d7
  735. .cline    cmp.b    #0,d7
  736.     beq    .gotline
  737.     add.l    #(4+(5*(4+4))),a0
  738.     sub.b    #1,d7
  739.     bra    .cline
  740. .gotline
  741.     ;copper line in a0
  742.     
  743.     move.l    screen1,a1
  744.     sub.l    #1,d0
  745. .ppos
  746.     add.l    #(5*scrwid),a1
  747.     dbra    d0,.ppos
  748.     ;that get to the middle of the piccy
  749.     ;add 40 lines to get to the bottom
  750.     add.l    #40*(5*scrwid),a1
  751.     
  752.     ;now place that line in a0 and sub all
  753.     
  754.     move.l    #20,d7
  755.     sub.l    d1,d7
  756.  
  757.     move.l    a1,d0
  758.     
  759.     move.l    d0,d1
  760.     move.l    a0,a2
  761. .pline
  762.  
  763.     move.l    #5-1,d6    
  764.     move.l    d1,d0
  765.     move.l    a2,a0
  766.  
  767. .plane    move.w    d0,6(a0)    ;bit1l
  768.     swap    d0
  769.     move.w    d0,2(a0)    ;bit1h
  770.     swap    d0
  771.     
  772.     add.l    #4+4,a0    ;next cline
  773.     add.l    #scrwid,d0    ;next gline
  774.     dbra    d6,.plane
  775.  
  776.     sub.l    #(5*(4+4))+4,a2
  777.     sub.l    #scrwid*5,d1
  778.     dbra    d7,.pline
  779.     
  780.     
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.     ;okay now dec inposb
  798.     
  799.     sub.b    #1,inposb
  800.     cmp.b    #0,inposb
  801.     bne    .nodone
  802.     ;hes finished!
  803.     move.b    #100,pftswait
  804.     move.b    #20,inposb
  805.     cmp.b    #114,inbaseb
  806.     beq    .go162
  807.     move.b    #114,inbaseb
  808.     bra    .nodone
  809. .go162
  810.     move.b    #162,inbaseb
  811.     
  812. .nodone
  813.  
  814.     rts    
  815.  
  816.  
  817. SetupALL
  818.     move.l    screen2,scrbase
  819.     bsr    back_to_screen    ;blit background on screen
  820.     move.l    screen1,scrbase
  821.     bsr    back_to_screen    ;blit background on screen
  822.     bsr    go_findlazer    ;search level for lazer cannon and copy strip
  823.  
  824.     move.l    screen1,scrbase
  825.     bsr    go_makelevel
  826.     bsr    go_findbads    ;search through level map for baddies!
  827.     bsr    go_findplayers    ;search through level map for player(s)
  828.     bsr    go_grabbads    ;grab baddies off screen (make coarse & smooth)
  829.     bsr    go_grabplayer1
  830.     bsr    go_grabbullets
  831.     move.l    screen2,scrbase
  832.     bchg    #1,switch
  833.     bsr    go_makelevel
  834.     bsr    go_grabbads    ;grab baddies off screen (make coarse & smooth)
  835.     bsr    go_grabplayer1
  836.     bsr    go_grabbullets
  837.  
  838.     lea    liveplayers,a1
  839.     clr.l    d0
  840.     clr.l    d7
  841.     move.b    num_players,d7    
  842.     sub.b    #1,d7    ;sub for dbra
  843. loop
  844.     move.b    d0,(a1,d0)
  845.     add.b    #1,d0
  846.     dbra    d7,loop
  847.     move.b    #$ff,(a1,d0)    ;terminate with ff
  848.     rts
  849.  
  850. go_findlazer
  851.     move.l    lazertempBase,a5
  852.     move.l    LevBase,a0    ;point to start of level
  853.     ;level data is in longs.
  854.     ;and #$ffff0000    to kill all but attr
  855.     ;the lazers are 55,56
  856.     move.l    #level_wid*level_hi-1,d7
  857.     clr.l    d1        ;counter
  858. .loop
  859.     move.l    (a0)+,d0
  860.     and.l    #$ffff0000,d0    ;kill all but attr
  861.     swap    d0
  862.  
  863.     cmp.b    #55,d0
  864.     bne    .notR
  865.     bsr    .gotR
  866.     
  867. .notR    cmp.b    #56,d0
  868.     bne    .notL
  869.     bsr    .gotL
  870. .notL
  871.     add.l    #1,d1        ;next one please
  872.     dbra    d7,.loop
  873.     
  874.     rts
  875. .gotR
  876.     ;copy 40 chars from here!->
  877.     ;d1 has got the char pos (div scr level_wid)
  878.     move.l    d1,d2
  879.     divu    #level_wid,d2
  880.     ;bottom word is line
  881.     ;high word is across
  882.     move.l    screen1,a2        ;source
  883.     add.l    #16*scrwid*5,a2
  884.     
  885.     move.l    d2,d3
  886.     and.l    #$0000ffff,d3
  887. .findy
  888.     cmp.w    #0,d3
  889.     beq    .foundy
  890.     sub.w    #1,d3
  891.     add.l    #16*scrwid*5,a2
  892.     bra    .findy    
  893. .foundy
  894.     
  895.     move.l    #(scrwid/2)*16*5-1,d6
  896. .copy1
  897.     move.w    (a2)+,(a5)+
  898.     dbra    d6,.copy1
  899.     rts
  900.     
  901. .gotL
  902.     ;copy 40 chars from here <-
  903.     ;d1 has got the char pos (div scr level_wid)
  904.     move.l    d1,d2
  905.     divu    #level_wid,d2
  906.     ;bottom word is line
  907.     ;high word is across
  908.     move.l    screen1,a2        ;source
  909.     add.l    #16*scrwid*5,a2
  910.     
  911.     move.l    d2,d3
  912.     and.l    #$0000ffff,d3
  913. .findy2
  914.     cmp.w    #0,d3
  915.     beq    .foundy2
  916.     sub.w    #1,d3
  917.     add.l    #16*scrwid*5,a2
  918.     bra    .findy2    
  919. .foundy2
  920.  
  921.     
  922.     move.l    #(scrwid/2)*16*5-1,d6
  923. .copy2
  924.     move.w    (a2)+,(a5)+
  925.     dbra    d6,.copy2
  926.  
  927.     rts
  928.  
  929. go_makelevel
  930.  
  931.     move.l    LevBase,a0    ;start of the level
  932.     
  933.     move.l    scrbase,a1
  934.     add.l    #(16*scrwid*5)+2,a1
  935.  
  936.     move.l    #level_hi-1,d6        ;how many down
  937. .loop2
  938.     move.l    #level_wid-1,d7    ;how many across
  939.     move.l    a0,a3    ;data
  940.     move.l    a1,a4    ;dest
  941. .loop
  942.     move.l    CharBase,a2
  943.     clr.l    d0
  944.     move.b    3(a3),d0    ;get data
  945.     move.l    d0,d1    ;save it for mask
  946.     mulu    #16*5*2,d0    ;get char
  947.     add.l    d0,a2
  948.     
  949.     bsr    go_make_mask
  950.     
  951.     bsr    go_blit_char
  952.  
  953.         
  954.     add.l    #4,a3    ;next longword data please
  955.     add.l    #2,a4    ;next screen pos please
  956.     dbra    d7,.loop
  957.     
  958.     add.l    #level_wid,a0
  959.     add.l    #level_wid,a0
  960.     add.l    #level_wid,a0
  961.     add.l    #level_wid,a0
  962.     
  963.     add.l    #scrwid*5*16,a1
  964.     dbra    d6,.loop2
  965.  
  966.     rts
  967. go_blit_char
  968.     ;blit a2 onto a4
  969.     
  970.     CALLGRAF    WaitBlit
  971.     move.l    #$ffffffff,$dff044
  972.     move.w    #0,$dff064        ;mod A
  973.     move.w    #scrwid-2,$dff062    ;mod B
  974.     move.w    #scrwid-2,$dff066    ;mod D
  975.     move.w    #$0,$dff042
  976.     move.w    #$0dfc,$dff040
  977.  
  978.     move.l    a2,$dff050    ;A
  979.     move.l    a4,$dff04c    ;dst B    screen
  980.     move.l    a4,$dff054    ;dst D    screen
  981.     move.w    #(16*5*64)+1,$dff058
  982.     rts
  983.  
  984. go_make_mask
  985.     move.l    MaskBase,a5
  986.     mulu    #16*1*2,d1    ;get mask
  987.     add.l    d1,a5
  988.     ;a4 has the dest!
  989.     move.l    a4,d1    ;save for later
  990.     
  991.     move.l    #5-1,d5    ;how many bitplanes!
  992. .loop    CALLGRAF    WaitBlit
  993.  
  994.     move.l    #$ffffffff,$dff044
  995.     move.w    #0,$dff064        ;mod A
  996.     move.w    #(scrwid*5)-2,$dff062    ;mod B
  997.     move.w    #(scrwid*5)-2,$dff066    ;mod D
  998.     move.w    #$0,$dff042
  999.     move.w    #$0d0c,$dff040
  1000.  
  1001.     move.l    a5,$dff050    ;A
  1002.     move.l    a4,$dff04c    ;dst B    screen
  1003.     move.l    a4,$dff054    ;dst D    screen
  1004.     move.w    #(16*1*64)+1,$dff058
  1005.     add.l    #scrwid,a4    ;next bitplane!
  1006.     dbra    d5,.loop
  1007.  
  1008.     move.l    d1,a4
  1009.     rts
  1010.     
  1011. randplayer
  1012.     ;do random player bit (0/1)
  1013.     clr.l    d6
  1014. .randloop    
  1015.  
  1016.     add.l    #1,d6    ;max time checking!
  1017.     cmp.l    #players_max*2,d6
  1018.     beq    .out
  1019.  
  1020.     clr.l    d0
  1021.     move.b    randplay,d0
  1022.     add.b    #1,d0
  1023.     cmp.b    #players_max,d0
  1024.     bne    .ok
  1025.     move.b    #0,d0
  1026. .ok
  1027.     move.b    d0,randplay
  1028.     
  1029.     move.l    d0,d7
  1030.     lea    player1,a1
  1031. .loop
  1032.     cmp.b    #0,d7
  1033.     beq    .gotim
  1034.     sub.b    #1,d7
  1035.     add.l    #player1_nd-player1,a1    ;next player
  1036.     bra    .loop
  1037. .gotim    
  1038.     cmp.b    #DEAD,play_status(a1)
  1039.     beq    .randloop
  1040.     
  1041.     
  1042. .out
  1043.     rts
  1044. go_findbads
  1045.     move.l    #0,spare
  1046.     
  1047.     ;first clear out bad_no table to kill all existing ones
  1048.     lea    bad_no,a1    ;pointer to baddy struct
  1049.     move.l    #bad_max-1,d7
  1050. .loop    move.l    #0,(a1)+
  1051.     dbra    d7,.loop
  1052.  
  1053.     ;look through level data for baddies
  1054.     move.l    LevBase,a0    ;point to start of level
  1055.     lea    bad_no,a1    ;pointer to baddy struct
  1056.     lea    bads_list,a4    ;baddy structure
  1057.         
  1058.     move.b    #bad_max,temp
  1059.     
  1060.     move.l    #16,d1    ;clear y
  1061.     move.w    #level_hi-1,d6
  1062. .loop3
  1063.     clr.l    d0    ;clear x
  1064.     move.w    #level_wid-1,d7
  1065.     move.l    a0,a2    ;pointer to level
  1066. .loop2
  1067.     move.l    (a2)+,d5
  1068.     and.l    #$ffff0000,d5    ;kill gfk information!
  1069.     swap    d5    ;switch words
  1070.  
  1071.     lea    bad_nums,a3    ;baddy numbers (attr)
  1072.     clr.l    d4
  1073.     
  1074. .loop4    cmp.l    #0,(a3,d4)    ;is it a baddy anyway?
  1075.     beq    .no_bad
  1076. ;    add.b    #1,random
  1077.     
  1078.     cmp.l    (a3,d4),d5    ;search for baddy number
  1079.     bne    .no_bad1
  1080.     ;found baddy!
  1081.     move.l    a4,(a1)+
  1082.     lea    bad_type1,a3
  1083.     PUSHALL
  1084.     bsr    create_baddy
  1085.     PULLALL
  1086.     add.l    #(bad_type1_nd-bad_type1),a4    ;next struct!
  1087.     sub.b    #1,temp
  1088.     cmp.b    #0,temp
  1089.     beq    .out
  1090.     bra    .no_bad
  1091. .no_bad1
  1092.     add.l    #4,d4
  1093.     bra    .loop4
  1094. .no_bad
  1095.     add.l    #16,d0    ;next x please
  1096.     dbra    d7,.loop2
  1097.     add.l    #level_wid*4,a0    ;next line please
  1098.     add.l    #16,d1    ;next y please
  1099.     dbra    d6,.loop3
  1100. .out    rts
  1101. create_baddy    
  1102.     ;send me the following
  1103.     ;a3 the baddy type structure
  1104.     ;a4 the structure of the baddy
  1105.     ;and i will copy the type structure (a3) in the baddy (a4)
  1106.  
  1107.     ;*** d4 has baddy number! *4 ***
  1108.     move.b    d5,spare+1        ;save for later
  1109.  
  1110.     move.l    a4,a5
  1111.     move.w    #(bad_type1_nd-bad_type1)-1,d5
  1112. .loop
  1113.     move.b    (a3)+,(a4)+
  1114.     dbra    d5,.loop
  1115.         
  1116.     ;also you should work out x & y pos
  1117.     move.w    d0,bad_x(a5)    ;save baddy x
  1118.     move.w    d1,bad_y(a5)    ;save baddy y
  1119.     
  1120.     ;now work out map pos
  1121.     move.w    d0,d2        ;
  1122.     and.l    #$0000fff0,d2    ;kill all orrible bits
  1123.     ror.w    #4,d2        ;shift down
  1124.     move.b    d2,bad_mapx(a5)        ;save baddy mapx
  1125.  
  1126.     move.w    d1,d2        ;
  1127.     and.l    #$0000fff0,d2    ;kill all orrible bits
  1128.     ror.w    #4,d2        ;shift down
  1129.     move.b    d2,bad_mapy(a5)        ;save baddy mapy
  1130.  
  1131.     clr.l    d2    ;x
  1132.     clr.l    d3    ;y
  1133.     move.w    bad_x(a5),d2    ;get baddy xpos
  1134.     move.w    bad_y(a5),d3    ;get baddy ypos
  1135.     
  1136.     mulu    #scrwid*5,d3    ;got y
  1137.     and.w    #$fff0,d2    ;do corse scrol
  1138.     ror.w    #3,d2
  1139.     add.w    d2,d3    ;got coarse
  1140.     
  1141.     move.l    d3,bad_act_was(a5)    ;save actual (just add scrbase)
  1142.     move.b    #OKAY,bad_status(a5)    ;hey im alright 
  1143.  
  1144.     move.b    #3,bad_hp(a5)    
  1145.  
  1146.     ;if its a lazer, do all this crap!
  1147.     cmp.b    #55,spare+1
  1148.     beq    .yes
  1149.     cmp.b    #56,spare+1
  1150.     beq    .yes
  1151.     bra    .no
  1152. .yes
  1153.     move.b    spare,bad_LBnk(a5)
  1154.     add.b    #1,spare
  1155. .no
  1156. BUM    ror.l    #2,d4        ;get down to normal
  1157.     
  1158.     move.l    d4,d0
  1159.     add.l    #1,d0    
  1160.  
  1161.     ;no. in d0    
  1162.     lea    asciinum,a0
  1163.     bsr    numtoasc
  1164.     
  1165.     lea    asciinum,a0
  1166.     lea    badascii,a3    ;copy the numbers across
  1167.     move.b    1(a0),5(a3)
  1168.     move.b    2(a0),6(a3)
  1169.     move.b    #0,7(a3)
  1170.  
  1171.     move.l    BadBase,a3
  1172.     sub.l    #10,a3        ;get to the start of its name again
  1173.     move.l    LDBase,d0
  1174.     add.l    LDSize,d0        ;go max size
  1175.     add.l    #20,d0        ;allow for fuckups!
  1176. .loop2
  1177.     move.l    #7-1,d7        ;how many chars
  1178.     lea    badascii,a4        ;(8 bytes)
  1179.     cmp.l    d0,a3
  1180.     bge    .lost
  1181.     cmp.b    (a4)+,(a3)+        ;are they the same?
  1182.     bne    .loop2        ;no
  1183.     ;groovy, ive found a match
  1184. .match2    cmp.b    (a4)+,(a3)+
  1185.     bne    .loop2
  1186.     dbra    d7,.match2
  1187.     ;a3 has start of baddy taglist!!!!
  1188.     
  1189.     clr.l    d0
  1190.     clr.l    d1
  1191. .taggin    cmp.b    #0,(a3)        ;2 zeros terminates taglist
  1192.     bne    .workin
  1193.     cmp.b    #0,1(a3)
  1194.     beq    .donetags
  1195. .workin    
  1196.     clr.l    d0
  1197.     clr.l    d1
  1198.     move.b    (a3)+,d0        ;get addr
  1199.     move.b    (a3)+,d1        ;get data
  1200.     move.b    d1,(a5,d0)        ;store them wherever
  1201.     bra    .taggin
  1202. .donetags
  1203.     
  1204.  
  1205. .lost    rts
  1206.     
  1207. go_grabbads
  1208.     lea    bad_no,a0    ;point to baddy list
  1209.     move.l    bad_temp1Base,a4    ;temp storage for grab
  1210.     btst    #1,switch
  1211.     bne    .loop
  1212.     move.l    bad_temp2Base,a4
  1213.     
  1214. .loop    
  1215.     move.l    (a0)+,a1        ;get baddy
  1216.     cmp.l    #0,a1
  1217.     beq    .no_bads
  1218.     ;a1 has baddy structure!
  1219.     cmp.b    #DYING,bad_status(a1)
  1220.     beq    .dead
  1221.     cmp.b    #DEAD,bad_status(a1)
  1222.     beq    .dead
  1223.     
  1224.     clr.l    d0    ;x
  1225.     clr.l    d1    ;y
  1226.     move.w    bad_x(a1),d0    ;get baddy xpos
  1227.     move.w    bad_y(a1),d1    ;get baddy ypos
  1228.     
  1229.     mulu    #scrwid*5,d1    ;got y
  1230.     move.w    d0,d2    ;save x
  1231.     and.w    #$000f,d0
  1232.     rol.w    #8,d0
  1233.     rol.w    #4,d0    ;got minterm
  1234.     and.w    #$fff0,d2    ;do corse scrol
  1235.     ror.w    #3,d2
  1236.     add.w    d2,d1    ;got coarse
  1237.     
  1238.     move.l    bad_actual(a1),d2
  1239.     move.l    d2,bad_act_was(a1)    ;save out the old actual
  1240.     move.l    d1,bad_actual(a1)    ;save actual (just add scrbase)
  1241.     move.w    d0,bad_smooth(a1)    ;save smooth (just add minterm)
  1242.  
  1243.     move.l    scrbase,a3
  1244.     add.l    d1,a3    ;got grab start
  1245.     ;blit a3 to a4 (screen to temp)
  1246.     
  1247.     CALLGRAF    WaitBlit
  1248.  
  1249.     cmp.b    #WeapLazer,bad_gun(a1)    ;is he a lazer weapon (1 word wide!)    
  1250.     bne    .nolaz
  1251.     move.w    #scrwid-2,$dff064    ;mod A
  1252.     move.w    #4-2,$dff066    ;mod D
  1253.     move.l    a3,$dff050    ;src A
  1254.     move.l    a4,$dff054    ;dst D
  1255.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  1256.     move.w    #(16*5*64)+1,$dff058    ;bltsize 
  1257.     
  1258.     bra    .ov
  1259. .nolaz
  1260.     ;do a little loop here to check if the baddy is in a lazerzone!
  1261.     ;dont use :=A0,A1,A3,A4,D0,D1,D2
  1262.     
  1263.     move.l    #bullet_max+1,d7
  1264.     
  1265.     lea    bullet_list,a2
  1266. .lazloop
  1267.     cmp.b    #WeapLazer,bull_gun(a2)
  1268.     bne    .deadlazer
  1269.     cmp.w    #0,bull_lazx(a2)
  1270.     bne    .ok1    ;its a lazer
  1271.     cmp.w    #0,bull_lazy(a2)
  1272.     beq    .deadlazer
  1273. .ok1
  1274.     ;ok, its a lazer beam..... do summink!
  1275.     
  1276.     ;if bad_x > bull_lazx AND bad_x2 < bull_lazx then possible kill
  1277.     ;if bad_y > bull_lazy AND bad_y2 < bull_layx then possible kill
  1278.     ;if both of these are TRUE then KILL murder death hurtalot
  1279.     ;    destruction of the poor little baddy!
  1280.     
  1281.     clr.l    d3
  1282.     move.w    bad_x(a1),d3
  1283.     
  1284.     cmp.w    bull_lazx(a2),d3
  1285.     blt    .safe
  1286.     cmp.w    bull_lazx2(a2),d3
  1287.     bgt    .safe
  1288.     
  1289.     
  1290.     clr.l    d3
  1291.     move.w    bad_y(a1),d3
  1292.     
  1293.     cmp.w    bull_lazy(a2),d3
  1294.     blt    .safe
  1295.     cmp.w    bull_lazy2(a2),d3
  1296.     bgt    .safe
  1297.     ;HAHHHAHAHAHHHHAAX KILL KILL BANG BANG YOUR DEAD KILL KILL
  1298. ;    move.b    #DYING,bad_status(a1)    
  1299.     move.b    #DEAD,bad_status(a1)    
  1300.     move.w    #$fff,flash
  1301.  
  1302.  
  1303. .safe    
  1304. .deadlazer    add.l    #bullet_nd-bullet,a2    ;next bullet
  1305.     dbra    d7,.lazloop
  1306.     
  1307.     move.w    #scrwid-4,$dff064    ;mod A
  1308.     move.w    #4-4,$dff066    ;mod D
  1309.     move.l    a3,$dff050    ;src A
  1310.     move.l    a4,$dff054    ;dst D
  1311.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  1312.     move.w    #(16*5*64)+2,$dff058    ;bltsize 
  1313. .ov
  1314. .dead    add.l    #16*5*4,a4        ;next gfk please
  1315.     bra    .loop        ;repeat until skipped!
  1316.  
  1317. .no_bads
  1318.     rts    
  1319.  
  1320. go_restorebads
  1321.     lea    bad_no,a0        ;baddy structure
  1322.     move.l    bad_temp1Base,a2        ;grabbed space
  1323.     btst    #1,switch
  1324.     bne    .loop
  1325.     move.l    bad_temp2Base,a2
  1326.  
  1327.     
  1328.     
  1329. .loop    move.l    (a0)+,a1        ;get bad structure
  1330.     cmp.l    #0,a1        ;is end of structure
  1331.     beq    .rest_all
  1332.  
  1333.     cmp.b    #DEAD,bad_status(a1)
  1334.     beq    .next
  1335.     move.l    scrbase,a3
  1336.     add.l    bad_act_was(a1),a3    ;add coarse
  1337.     ;blit a2 to a3 please
  1338.     
  1339.     CALLGRAF    WaitBlit
  1340.     cmp.b    #WeapLazer,bad_gun(a1)    ;if lazer weapon (1 word wide)
  1341.     bne    .nolazer
  1342.     move.w    #4-2,$dff064    ;mod A
  1343.     move.w    #scrwid-2,$dff066    ;mod D
  1344.     move.l    a2,$dff050    ;src A
  1345.     move.l    a3,$dff054    ;dst D
  1346.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  1347.     move.w    #(16*5*64)+1,$dff058    ;bltsize 
  1348.     bra    .ov
  1349.     
  1350. .nolazer
  1351.  
  1352.     move.w    #4-4,$dff064    ;mod A
  1353.     move.w    #scrwid-4,$dff066    ;mod D
  1354.     move.l    a2,$dff050    ;src A
  1355.     move.l    a3,$dff054    ;dst D
  1356.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  1357.     move.w    #(16*5*64)+2,$dff058    ;bltsize 
  1358. .ov    
  1359. .next    add.l    #16*5*4,a2        ;next 1 please
  1360.     
  1361.     cmp.b    #DYING,bad_status(a1)
  1362.     bne    .nodying
  1363.     add.b    #1,bad_dedcnt(a1)
  1364.     cmp.b    #2,bad_dedcnt(a1)
  1365.     bne    .nodying
  1366.     move.b    #DEAD,bad_status(a1)
  1367. .nodying
  1368.     bra    .loop
  1369. .rest_all
  1370.     rts
  1371.     
  1372. go_printbads
  1373.     lea    bad_no,a0        ;baddy structure
  1374.     
  1375. .loop    move.l    (a0)+,a1        ;get bad structure
  1376.     cmp.l    #0,a1        ;is end of structure
  1377.     beq    .plot_all
  1378.  
  1379.     cmp.b    #DYING,bad_status(a1)
  1380.     beq    .loop
  1381.     cmp.b    #DEAD,bad_status(a1)
  1382.     beq    .loop
  1383.     
  1384.     move.l    scrbase,a3
  1385.     add.l    bad_actual(a1),a3    ;add coarse scroll
  1386.  
  1387.     ;A = mask
  1388.     ;B = source
  1389.     ;C = dest
  1390.     ;D = dest. (obvious really!!)
  1391.     
  1392.     CALLGRAF    WaitBlit
  1393.     move.w    #$ffff,$dff044    ;fwm
  1394.     move.w    #$ffff,$dff046    ;lwm
  1395.  
  1396.     move.w    bad_smooth(a1),d0    ;get smooth
  1397.     move.w    d0,$dff042    
  1398.     or.w    #$0fce,d0
  1399.     move.w    d0,$dff040    
  1400.     
  1401.     move.l    scrbase,a4        ;get coarse
  1402.     add.l    bad_actual(a1),a4
  1403.     
  1404.     clr.l    d0
  1405.     move.l    Baddy1Base,a5
  1406.  
  1407.     move.b    bad_gfxnum(a1),d0
  1408. .findgfx
  1409.     cmp.l    #0,d0
  1410.     beq    .nogfx
  1411.     add.l    #80*5*32,a5
  1412.     dbra    d0,.findgfx
  1413. .nogfx
  1414.     
  1415.     clr.l    d0
  1416. ;    lea    baddies,a5        ;get baddies
  1417.     move.b    bad_anim(a1),d0    ;get anim no.
  1418.     
  1419.     ;figure out what gfk to display
  1420.     ;get direction to suss which gfks to use
  1421.     clr.l    d1
  1422.     lea    bad_an_rcnt(a1),a2    ;get actuall addr
  1423.     move.b    bad_an_off(a1),d1
  1424.     add.l    #1,a2        ;skip counter
  1425.     add.l    d1,a2        ;found bank!
  1426.     add.l    d0,a2        ;found char
  1427.     
  1428.     clr.l    d0
  1429.     move.b    (a2),d0        ;get char
  1430.     
  1431.     rol.l    #2,d0        ;make long!
  1432.     add.l    d0,a5        ;got baddy
  1433.     
  1434.     move.l    a5,a3        ;get baddy mask
  1435.     add.l    #(80*16*5),a3
  1436.  
  1437.     cmp.b    #WeapLazer,bad_gun(a1)    ;is he a lazer weapon (only 1 word wide!)
  1438.     bne    .nolaz
  1439.     move.w    #80-2,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  1440.     move.w    #80-2,$dff062    ;mod b
  1441.     move.w    #scrwid-2,$dff060    ;mod C
  1442.     move.w    #scrwid-2,$dff066    ;mod D
  1443.     
  1444.     move.l    a3,$dff050    ;get mask A
  1445.     move.l    a5,$dff04c    ;src B    bob
  1446.     move.l    a4,$dff048    ;src C    screen
  1447.     move.l    a4,$dff054    ;dst D    screen
  1448.     move.w    #(16*5*64)+1,$dff058
  1449.     
  1450.     bra    .ov
  1451. .nolaz
  1452.     move.w    #80-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  1453.     move.w    #80-4,$dff062    ;mod b
  1454.     move.w    #scrwid-4,$dff060    ;mod C
  1455.     move.w    #scrwid-4,$dff066    ;mod D
  1456.     
  1457.     move.l    a3,$dff050    ;get mask A
  1458.     move.l    a5,$dff04c    ;src B    bob
  1459.     move.l    a4,$dff048    ;src C    screen
  1460.     move.l    a4,$dff054    ;dst D    screen
  1461.     move.w    #(16*5*64)+2,$dff058
  1462. .ov    
  1463.     bra    .loop
  1464. .plot_all
  1465.  
  1466.     rts
  1467.  
  1468. go_find_speed
  1469.     move.w    bad_x(a1),d1
  1470.     and.l    #$0000fff0,d1    ;kill off old xpos fine
  1471.  
  1472.     clr.l    d0
  1473.     
  1474.     btst    #LOOKB_MARIO,bad_look(a1);am i in mario mode?
  1475.     beq    .marior        ;nope
  1476.     ;in mario mode so work out speed
  1477.     ;dont corrupt d1 and put speed into d0
  1478.     lea    bad_walk,a2
  1479.     clr.l    d0
  1480.     ;dont add if falling!
  1481.     btst    #BOBB_FALL,bad_doing(a1);hey! am I falling....
  1482.     bne    .dont
  1483.     
  1484.     add.b    #1,bad_mar(a1)    ;next table pos
  1485. .dont    move.b    bad_mar(a1),d0
  1486.     cmp.b    bad_mar_max(a1),d0    ;at max speed?
  1487.     blt    .nope
  1488.     ;reached max
  1489.     sub.b    #1,bad_mar(a1)
  1490.     sub.b    #1,d0
  1491. .nope
  1492.     move.b    (a2,d0),d0        ;get speed
  1493.     
  1494.     bra    .mariomoder
  1495.  
  1496. .marior
  1497.     move.b    bad_speed(a1),d0
  1498.  
  1499. .mariomoder
  1500.  
  1501.     rts    
  1502. setup_fall
  1503.     btst    #BOBB_FALL,bad_doing(a1)    ;if already falling then dont setup
  1504.     bne    .oldun
  1505.     ;first time to fall, set it all up please!
  1506.     move.b    #0,bad_fal(a1)    ;reset his fall thingy
  1507.     bset    #BOBB_FALL,bad_doing(a1)    ;hey! im falling....
  1508.     bset    #BOBB_DOWN,bad_go(a1)    ;set going down bit please 
  1509. .oldun    cmp.b    #0,bad_mar(a1)    ;slow down his x movement
  1510.     beq    .slowedx
  1511.     sub.b    #1,bad_mar(a1)    ;slow down now please X
  1512. .slowedx    add.b    #1,bad_fal(a1)    ;fall ya bastard!
  1513.     move.b    bad_fal(a1),d0
  1514.     cmp.b    bad_fal_max(a1),d0    ;is it max
  1515.     blt    .out
  1516.     sub.b    #1,bad_fal(a1)    ;at max go down 1
  1517.  
  1518. .out    rts
  1519. go_movebads
  1520.     lea    bad_no,a0        ;baddy structure
  1521.     
  1522. .loop    move.l    (a0)+,a1        ;get bad structure
  1523.     cmp.l    #0,a1        ;is end of structure
  1524.     beq    .moved_all
  1525.  
  1526.     cmp.b    #DEAD,bad_status(a1)
  1527.     beq    .loop
  1528.     bsr    do_bad_norm
  1529.     
  1530.  
  1531.     bra    .loop
  1532. .moved_all
  1533.     rts
  1534.  
  1535. go_rand
  1536.     move.b    bad_rand2(a1),d0
  1537.     cmp.b    random,d0
  1538.     bne    .out
  1539.     btst    #BOBB_JUMP,bad_ability(a1)    ;can i jump?
  1540.     beq    .no_jump        ;no
  1541.     btst    #BOBB_JUMP,bad_doing(a1)    ;am i already jumping?
  1542.     bne    .no_jump        ;yes
  1543.     btst    #BOBB_FALL,bad_doing(a1)    ;dont jump if falling
  1544.     bne    .no_jump        ;sorry, falling
  1545.     bset    #BOBB_JUMP,bad_doing(a1)    ;hey jump!
  1546.     move.b    #24,bad_jmp_pos(a1)    ;starting jump no.!
  1547. .no_jump
  1548. .out
  1549.     rts
  1550. do_bad_norm    ;dont corrupt a0 (a1 is your structure)
  1551.  
  1552.  
  1553.     bsr    go_rand
  1554.     bsr    go_shoot
  1555.     bsr    anim_baddy
  1556.  
  1557.     btst    #BOBB_RIGHT,bad_go(a1)    ;am i going right?
  1558.     beq    .not_right
  1559.  
  1560. ;    bsr    anim_baddy
  1561.  
  1562.     bsr    go_find_speed    ;gets baddy speed (d0=new/d1=old)
  1563.  
  1564.     add.w    d0,bad_x(a1)    ;move right please
  1565.  
  1566.     ;if not a platform dude then skip all this crap
  1567.     btst    #BOBB_PLAT,bad_ability(a1)
  1568.     beq    .nock
  1569.     
  1570.     add.b    d0,bad_platx(a1)
  1571.     cmp.b    #32,bad_platx(a1)
  1572.     ble    .nock
  1573.     sub.b    #16,bad_platx(a1)
  1574.  
  1575.     cmp.b    #21,bad_mapx(a1)
  1576.     blt    .onscree
  1577.     move.b    #21,bad_mapx(a1)
  1578.     move.w    #21*16,bad_x(a1)
  1579.     move.b    #16,bad_platx(a1)
  1580.     bra    .jumpsu
  1581. .onscree
  1582.     add.b    #1,bad_mapx(a1)
  1583. .jumpsu
  1584.  
  1585.     ;if hes jumping then dont check collision
  1586.     btst    #BOBB_JUMP,bad_doing(a1)
  1587.     bne    .nock
  1588.     btst    #BOBB_FALL,bad_doing(a1)
  1589.     bne    .nock
  1590.     
  1591.     ;if bit 8 is set then check what he walking on
  1592.     btst    #BOBB_PLAT,bad_ability(a1)
  1593.     beq    .nock
  1594. ;this will check what to the right!
  1595.     move.b    bad_mapx(a1),d0
  1596. ;    add.b    #1,d0        ;check 1 extra to the right
  1597.     move.b    bad_mapy(a1),d1
  1598.     bsr    find_char        ;get whats below me (d0)
  1599.     lea    walk_thru,a2    ;what chars can you walk thru
  1600. .find_side1
  1601.     cmp.b    #0,(a2)
  1602.     beq    .ok        ;hes not running into anything
  1603.     
  1604.     cmp.b    (a2)+,d0    ;is it thru char?
  1605.     beq    .turn    ;yes
  1606.     bra    .find_side1
  1607. .ok
  1608.  
  1609. ;this will check what to the right up!
  1610.     ;if jumping or falling!
  1611.     btst    #BOBB_JUMP,bad_doing(a1)
  1612.     bne    .docheckur
  1613.     btst    #BOBB_FALL,bad_doing(a1)
  1614.     bne    .docheckur
  1615.     bra    .okur
  1616. .docheckur
  1617.     move.b    bad_mapx(a1),d0
  1618.     move.b    bad_mapy(a1),d1
  1619.     add.b    #1,d1        ;check 1 extra above right
  1620.     bsr    find_char        ;get whats below me (d0)
  1621.     lea    walk_thru,a2    ;what chars can you walk thru
  1622. .find_topside1
  1623.     cmp.b    #0,(a2)
  1624.     beq    .okur        ;hes not running into anything
  1625.     
  1626.     cmp.b    (a2)+,d0    ;is it thru char?
  1627.     beq    .turn    ;yes
  1628.     bra    .find_topside1
  1629. .okur
  1630.  
  1631. ;this will check what hes walking on!
  1632.     move.b    bad_mapx(a1),d0
  1633.     btst    #BOBB_FALL,bad_ability(a1)
  1634.     bne    .canf
  1635.     add.b    #1,d0        ;check 1 extra to the right
  1636. .canf
  1637. ;    add.b    #1,d0        ;check 1 extra to the right
  1638.     move.b    bad_mapy(a1),d1
  1639.     add.b    #1,d1
  1640.     bsr    find_char        ;get whats below me (d0)
  1641.     lea    walk_on,a2        ;what chars can you walk on
  1642. .find_floor2
  1643.     cmp.b    #0,(a2)
  1644.     beq    .setup_fallr
  1645.     cmp.b    (a2)+,d0
  1646.     bne    .find_floor2
  1647.     bra    .same
  1648. .setup_fallr
  1649.     btst    #BOBB_FALL,bad_ability(a1)
  1650.     beq    .turn        ;cant fall!! so turn him
  1651.  
  1652.     bsr    setup_fall
  1653. .same
  1654.     
  1655. .nock
  1656.     
  1657.     cmp.w    #320+16-16,bad_x(a1)    ;edge of screen?
  1658.     blt    .okay
  1659.     move.w    #320+16-16,bad_x(a1)    ;edge of screen?
  1660.     move.b    #20,bad_mapx(a1)
  1661.  
  1662. .turn    ;at edge, please turn around
  1663.  
  1664.     move.w    bad_x(a1),d0
  1665.     and.w    #$fff0,d0
  1666.     move.w    d0,bad_x(a1)
  1667.     move.b    #16,bad_platx(a1)
  1668.     ;if a mario baddy then reset bad_mar counter to 0
  1669.     btst    #LOOKB_MARIO,bad_look(a1)    ;am i in mario mode?
  1670.     beq    .no_reset_marior        ;nope
  1671.     move.b    #0,bad_mar(a1)
  1672. .no_reset_marior
  1673.  
  1674.     bclr    #BOBB_RIGHT,bad_go(a1)    ;clear right
  1675.     bset    #BOBB_LEFT,bad_go(a1)    ;set left
  1676.     move.b    #9,bad_an_off(a1)    ;set his gfx left
  1677. .okay
  1678.     bra    .not_left
  1679. .not_right
  1680.     btst    #BOBB_LEFT,bad_go(a1)    ;am i going left?
  1681.     beq    .not_left
  1682.  
  1683. ;    bsr    anim_baddy
  1684.  
  1685.     bsr    go_find_speed    ;gets baddy speed (d0=new/d1=old)
  1686.     
  1687.     sub.w    d0,bad_x(a1)    ;move left please
  1688.  
  1689.     ;if not a platform dude then skip all this crap
  1690.     btst    #BOBB_PLAT,bad_ability(a1)
  1691.     beq    .same2
  1692.  
  1693.     sub.b    d0,bad_platx(a1)
  1694.     cmp.b    #0,bad_platx(a1)
  1695.     bge    .same2
  1696.     add.b    #16,bad_platx(a1)
  1697.  
  1698.     cmp.b    #0,bad_mapx(a1)
  1699.     bgt    .onscreen
  1700.     ;shit off screen
  1701.     move.w    #0,bad_x(a1)    ;reset
  1702.     bra    .jumpsub
  1703. .onscreen
  1704.     sub.b    #1,bad_mapx(a1)
  1705. .jumpsub
  1706.  
  1707.     ;if hes jumping then dont check collision
  1708.     btst    #BOBB_JUMP,bad_doing(a1)
  1709.     bne    .same2
  1710.     btst    #BOBB_FALL,bad_doing(a1)
  1711.     bne    .same2
  1712.  
  1713.     ;if bit 8 is set then check what he walking on
  1714.     btst    #BOBB_PLAT,bad_ability(a1)
  1715.     beq    .same2
  1716. ;this will check what to the left!
  1717.     move.b    bad_mapx(a1),d0
  1718.     move.b    bad_mapy(a1),d1
  1719.     bsr    find_char        ;get whats below me (d0)
  1720.     lea    walk_thru,a2    ;what chars can you walk thru
  1721. .find_side2
  1722.     cmp.b    #0,(a2)
  1723.     beq    .ok2        ;hes not running into anything
  1724.     
  1725.     cmp.b    (a2)+,d0    ;is it thru char?
  1726.     beq    .turn2    ;yes
  1727.     bra    .find_side2
  1728. .ok2
  1729. ;this will check what to the left up!
  1730.     ;if jumping or falling!
  1731.     btst    #BOBB_JUMP,bad_doing(a1)
  1732.     bne    .docheckul
  1733.     btst    #BOBB_FALL,bad_doing(a1)
  1734.     bne    .docheckul
  1735.     bra    .okul
  1736. .docheckul
  1737.     move.b    bad_mapx(a1),d0
  1738.  
  1739.     move.b    bad_mapy(a1),d1
  1740.     add.b    #1,d1        ;check 1 extra above right
  1741.     bsr    find_char        ;get whats below me (d0)
  1742.     lea    walk_thru,a2    ;what chars can you walk thru
  1743. .find_topside2
  1744.     cmp.b    #0,(a2)
  1745.     beq    .okul        ;hes not running into anything
  1746.     
  1747.     cmp.b    (a2)+,d0    ;is it thru char?
  1748.     beq    .turn2    ;yes
  1749.     bra    .find_topside2
  1750. .okul
  1751.  
  1752. ;this will check what hes walking on
  1753.     move.b    bad_mapx(a1),d0
  1754.     btst    #BOBB_FALL,bad_ability(a1)
  1755.     bne    .canfa
  1756.     sub.b    #1,d0        ;check 1 extra to the right
  1757. .canfa
  1758.  
  1759.     move.b    bad_mapy(a1),d1
  1760.     add.b    #1,d1
  1761.     bsr    find_char        ;get whats below me (d0)    
  1762.     lea    walk_on,a2        ;what chars can you walk on
  1763. .find_floor    cmp.b    #0,(a2)
  1764.     beq    .setup_falll
  1765.     cmp.b    (a2)+,d0
  1766.     bne    .find_floor
  1767.     bra    .same2
  1768. .setup_falll
  1769.     btst    #BOBB_FALL,bad_ability(a1)
  1770.     beq    .turn2
  1771.     
  1772.     bsr    setup_fall
  1773.  
  1774. .same2
  1775.  
  1776.     cmp.w    #16,bad_x(a1)    ;edge of screen?
  1777.     bgt    .okay2
  1778.     move.w    #16,bad_x(a1)
  1779.     bra    .banana
  1780. .turn2    ;at edge, please turn around
  1781.     move.w    bad_x(a1),d0
  1782.     or.w    #$000f,d0
  1783.     move.w    d0,bad_x(a1)
  1784.     move.b    #16,bad_platx(a1)
  1785. .banana
  1786.     ;if a mario baddy then reset bad_mar counter to 0
  1787.     btst    #LOOKB_MARIO,bad_look(a1)        ;am i in mario mode?
  1788.     beq    .no_reset_mariol        ;nope
  1789.     move.b    #0,bad_mar(a1)
  1790. .no_reset_mariol
  1791.  
  1792.  
  1793.     bclr    #BOBB_LEFT,bad_go(a1)    ;clear left
  1794.     bset    #BOBB_RIGHT,bad_go(a1)    ;set right
  1795.     move.b    #0,bad_an_off(a1)    ;set his gfx right
  1796. .okay2
  1797.     bra    .not_left
  1798. .not_left
  1799.  
  1800.     ;dont do this routine if im jumping
  1801.     btst    #BOBB_JUMP,bad_doing(a1);am i jumping?
  1802.     bne    .not_down        ;yes, skip it all
  1803.     
  1804.     btst    #BOBB_DOWN,bad_go(a1)    ;am i going down?
  1805.     beq    .not_down
  1806.  
  1807.     btst    #BOBB_FALL,bad_doing(a1);hey! am i falling....
  1808.     beq    .notfall
  1809.     move.b    bad_fal(a1),d0
  1810.     cmp.b    bad_fal_max(a1),d0    ;is it max
  1811.     blt    .fallmax
  1812.     sub.b    #1,bad_fal(a1)    ;at max go down 1
  1813. .fallmax
  1814.     bra    .falling
  1815.  
  1816.  
  1817. .notfall
  1818.  
  1819. .falling
  1820.     move.w    bad_y(a1),d1
  1821.     and.l    #$0000fff0,d1    ;kill off old xpos fine
  1822.  
  1823.  
  1824.     lea    bad_walk,a2
  1825.     clr.l    d0
  1826.     
  1827.     add.b    #1,bad_fal(a1)    ;next table pos
  1828.     move.b    bad_fal(a1),d0
  1829.     cmp.b    bad_fal_max(a1),d0    ;at max speed?
  1830.     blt    .freefal
  1831.     ;reached max
  1832.     sub.b    #1,bad_fal(a1)
  1833.     sub.b    #1,d0
  1834. .freefal
  1835.     move.b    (a2,d0),d0        ;get speed
  1836.     
  1837.  
  1838.  
  1839.     add.w    d0,bad_y(a1)    ;move down please
  1840.  
  1841.     move.w    bad_y(a1),d0    ;
  1842.     and.l    #$0000fff0,d0    ;kill off new xpos fine
  1843.     cmp.b    d0,d1
  1844.     beq    .same3        ;hasnt crossed boundary!
  1845.     add.b    #1,bad_mapy(a1)
  1846.  
  1847.     btst    #BOBB_PLAT,bad_ability(a1)
  1848.     beq    .nock
  1849. ;this will check under
  1850.     move.b    bad_mapx(a1),d0
  1851.     move.b    bad_mapy(a1),d1
  1852.     add.b    #1,d1
  1853.     ;if moving to the right then add #1,d0 (unless speed = 0????)
  1854. ;    add.b    #1,d0
  1855.  
  1856.  
  1857.     bsr    find_char        ;get whats below me (d0)
  1858.     lea    walk_on,a2    ;what chars can you walk on
  1859. .find_under1
  1860.     cmp.b    #0,(a2)
  1861.     beq    .morefall        ;hes not running on anything
  1862.     
  1863.     cmp.b    (a2)+,d0    ;is it on char?
  1864.     bne    .find_under1    ;no
  1865.     ;right, summink i can walk on!
  1866.     bclr    #BOBB_DOWN,bad_go(a1)    ;clear going down?
  1867.     bclr    #BOBB_FALL,bad_doing(a1)    ;clear falling....
  1868.     move.b    #0,bad_fal(a1)    ;clear fall couhter
  1869.     move.w    bad_y(a1),d0
  1870.     and.w    #$fff0,d0        ;put him on the top of the char
  1871.     move.w    d0,bad_y(a1)    ;store it again
  1872.     bra    .not_down
  1873.     
  1874. .morefall
  1875.     ;get platx if under 16 then sub 1 d0
  1876.     ;if over 16 then add 1 d0
  1877.     clr.l    d0
  1878.     clr.l    d1
  1879.     move.b    bad_mapx(a1),d0
  1880.     move.b    bad_mapy(a1),d1
  1881.     add.b    #1,d1
  1882.  
  1883.     
  1884.     cmp.b    #16,bad_platx(a1)    ;check smooth scroll
  1885.     bgt    .over16
  1886.     blt    .under16
  1887.     beq    .same3
  1888. .over16
  1889.     add.l    #1,d0
  1890.     bra    .check
  1891. .under16
  1892.     sub.l    #1,d0
  1893. .check
  1894.     bsr    find_char        ;get whats below me (d0)
  1895.     lea    walk_on,a2    ;what chars can you walk on
  1896. .find_underm
  1897.     cmp.b    #0,(a2)
  1898.     beq    .same3        ;hes not running on anything
  1899.     
  1900.     cmp.b    (a2)+,d0    ;is it on char?
  1901.     bne    .find_underm    ;no
  1902.     ;right, summink i can walk on!
  1903.     bclr    #BOBB_DOWN,bad_go(a1)    ;clear going down?
  1904.     bclr    #BOBB_FALL,bad_doing(a1)    ;clear falling....
  1905.     move.b    #0,bad_fal(a1)    ;clear fall couhter
  1906.     move.w    bad_y(a1),d0
  1907.     and.w    #$fff0,d0        ;put him on the top of the char
  1908.     move.w    d0,bad_y(a1)    ;store it again
  1909.     bra    .not_down
  1910.  
  1911. .same3
  1912.  
  1913.     cmp.w    #(scrhi*16)-16,bad_y(a1)    ;edge of screen?
  1914.     blt    .okay3
  1915.  
  1916.     ;if falling off screen reset him to top
  1917.     move.b    #0,bad_mapy(a1)
  1918.     move.w    #0,bad_y(a1)
  1919.     
  1920.     ;at edge, please turn around
  1921. ;    bclr    #BOBB_DOWN,bad_go(a1)    ;clear down
  1922. ;    bset    #BOBB_UP,bad_go(a1)    ;set up
  1923. .okay3
  1924.     bra    .not_up
  1925. .not_down
  1926.  
  1927.     ;am i jumping?
  1928.     btst    #BOBB_JUMP,bad_doing(a1)
  1929.     bne    .over
  1930.     
  1931.     btst    #BOBB_UP,bad_go(a1)    ;am i going up?
  1932.     beq    .not_up
  1933.  
  1934. .over    move.w    bad_y(a1),d1
  1935.     and.l    #$0000fff0,d1    ;kill off old xpos fine
  1936.  
  1937.     clr.l    d0
  1938.     ;if in jump mode then get speed!
  1939.     btst    #BOBB_JUMP,bad_doing(a1)
  1940.     beq    .skipd0        ;not jumping
  1941.     cmp.b    #0,bad_jmp_pos(a1)
  1942.     bne    .no_climax
  1943.     ;reached top of jump. now switch off jump and gravity do the rest!
  1944.     bclr    #BOBB_JUMP,bad_doing(a1)    ;stop jumpping ya bastard
  1945.     bset    #BOBB_FALL,bad_doing(a1)    ;fall ya bastard
  1946.     bset    #BOBB_DOWN,bad_go(a1)    ;set going down bit please 
  1947.     move.b    #0,bad_fal(a1)
  1948.     ;if char under is walkonable then sort out ypos
  1949. ;    move.w    bad_y(a1),d0
  1950. ;    and.w    #$fff0,d0
  1951. ;    move.w    d0,bad_y(a1)
  1952. ;    sub.b    #1,bad_mapy(a1)
  1953.     bra    .not_up
  1954. .no_climax
  1955.     sub.b    #1,bad_jmp_pos(a1)
  1956.     move.b    bad_jmp_pos(a1),d0    ;get the counter
  1957.     lea    bad_jump,a2
  1958.     move.b    (a2,d0),d0        ;got the speed!
  1959.     bra    .skipd0
  1960.     
  1961.     
  1962.     move.b    bad_speed(a1),d0
  1963. .skipd0
  1964.     sub.w    d0,bad_y(a1)    ;move up please
  1965.  
  1966.     move.w    bad_y(a1),d0    ;
  1967.     and.l    #$0000fff0,d0    ;kill off new xpos fine
  1968.     cmp.b    d0,d1
  1969.     beq    .same4        ;hasnt crossed boundary!
  1970.     sub.b    #1,bad_mapy(a1)
  1971.     ;check above baddy just for walk_thru chars
  1972.     move.b    bad_mapx(a1),d0
  1973.     move.b    bad_mapy(a1),d1
  1974. ;    add.b    #1,d1
  1975.     ;if moving to the right then add #1,d0 (unless speed = 0????)
  1976. ;    add.b    #1,d0
  1977.  
  1978.  
  1979.     bsr    find_char        ;get whats below me (d0)
  1980.     lea    walk_thru,a2    ;what chars can you walk thru
  1981. .find_above1
  1982.     cmp.b    #0,(a2)
  1983.     beq    .same4        ;its ok.
  1984.     cmp.b    (a2)+,d0
  1985.     bne    .find_above1    ;keep looking!
  1986.     ;damn, he cant jump up through this block. kill off his jump!
  1987.     add.b    #1,bad_mapy(a1)    ;reset coarse
  1988.     add.w    #16,bad_y(a1)
  1989.     move.w    bad_y(a1),d0
  1990.     and.l    #$0000fff0,d0
  1991.     move.w    d0,bad_y(a1)
  1992.     bclr    #BOBB_JUMP,bad_doing(a1)    ;clr jumping bit
  1993.     move.b    #0,bad_jmp_pos(a1)    ;reset jump counter!
  1994.     bra    .not_up
  1995.  
  1996.  
  1997.  
  1998.  
  1999. .same4
  2000.  
  2001.     cmp.w    #0,bad_y(a1)    ;edge of screen?
  2002.     bgt    .okay4
  2003.     ;at edge, please turn around
  2004.     move.w    #0,bad_y(a1)
  2005.     move.b    #0,bad_mapy(a1)
  2006.     bclr    #BOBB_UP,bad_go(a1)    ;clear up
  2007.     bset    #BOBB_DOWN,bad_go(a1)    ;set down
  2008. .okay4
  2009.     bra    .not_up
  2010. .not_up
  2011.  
  2012.  
  2013.     rts
  2014.  
  2015. go_printguns
  2016.  
  2017.     move.b    #1,PlayerGun
  2018.  
  2019.     move.l    #gun_max-1,d7
  2020.  
  2021.     lea    gun_list,a2
  2022.     bra    mainprintbull
  2023.  
  2024.  
  2025.  
  2026. go_printbullets
  2027.  
  2028. ;change the next 2 lines to acc.....
  2029.  
  2030.     move.l    #bullet_max-1,d7
  2031.  
  2032.     lea    bullet_list,a2
  2033.  
  2034.  
  2035. mainprintbull
  2036.     
  2037.     move.w    #$ffff,$dff044    ;fwm
  2038.     move.w    #$ffff,$dff046    ;lwm
  2039.     move.w    #40-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  2040.     move.w    #40-4,$dff062    ;mod b
  2041.     move.w    #scrwid-4,$dff060    ;mod C
  2042.     move.w    #scrwid-4,$dff066    ;mod D
  2043.  
  2044. .loop
  2045.     cmp.b    #WeapLazer,bull_gun(a2)
  2046.     beq    .bulldead
  2047.  
  2048.     cmp.b    #DEAD,bull_status(a2)
  2049.     beq    .bulldead
  2050.     cmp.b    #DYING,bull_status(a2)    ;on his way
  2051.     beq    .bulldead
  2052.  
  2053.     ;A = mask
  2054.     ;B = source
  2055.     ;C = dest
  2056.     ;D = dest. (obvious really!!)
  2057.  
  2058.     move.w    bull_smooth(a2),d0    ;get smooth
  2059.     move.w    d0,$dff042    
  2060.     or.w    #$0fce,d0
  2061.     move.w    d0,$dff040    
  2062.     
  2063.     move.l    scrbase,a4        ;get coarse
  2064.     add.l    bull_actual(a2),a4
  2065.  
  2066.     clr.l    d0
  2067.     move.b    bull_wantgo(a2),d0    ;find what gfk to use
  2068.     btst    #BOBB_LEFT,d0
  2069.     beq    .goingr
  2070.     move.l    #4,d0
  2071.     bra    .skip
  2072. .goingr
  2073.     clr.l    d0
  2074. .skip        
  2075.     move.l    Bullet1Base,a5
  2076.     clr.l    d1
  2077.     move.w    bull_gfk(a2),d1
  2078.     
  2079.     
  2080.     ;if d1 > 40 then add 40*16*5,a5
  2081. .loopin
  2082.     cmp.b    #40,d1
  2083.     bmi    .ok
  2084.     add.l    #80*16*5,a5
  2085.     sub.l    #40,d1
  2086.     bra    .loopin
  2087. .ok
  2088.     add.l    d1,a5
  2089.     
  2090.  
  2091.     move.l    a5,a3
  2092.     add.l    #40*16*5,a3        ;get to mask!
  2093.     add.l    d0,a3
  2094.     add.l    d0,a5
  2095.     
  2096.     move.l    a3,$dff050    ;get mask A
  2097.     move.l    a5,$dff04c    ;src B    bob
  2098.     move.l    a4,$dff048    ;src C    screen
  2099.     move.l    a4,$dff054    ;dst D    screen
  2100.     move.w    #(16*5*64)+2,$dff058
  2101.  
  2102.     PUSHALL
  2103.     CALLGRAF    WaitBlit
  2104.     PULLALL
  2105.  
  2106. .bulldead
  2107.     add.l    #bullet_nd-bullet,a2    ;next bullet
  2108.     dbra    d7,.loop
  2109.  
  2110.     move.b    #0,PlayerGun
  2111.     rts
  2112.  
  2113. go_printlazer
  2114.  
  2115. ;change the next 2 lines to acc.....
  2116.  
  2117.     move.l    #bullet_max-1,d7
  2118.  
  2119.     lea    bullet_list,a2
  2120.  
  2121.     PUSHALL
  2122.     CALLGRAF    WaitBlit
  2123.     PULLALL
  2124.  
  2125.     move.w    #$ffff,$dff044    ;fwm
  2126.     move.w    #$ffff,$dff046    ;lwm
  2127.     move.w    #40-2,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  2128.     move.w    #scrwid-2,$dff066    ;mod D
  2129.  
  2130.     move.w    #0,$dff042    
  2131.     move.w    #$09f0,$dff040    
  2132.  
  2133.  
  2134. .loop
  2135.     cmp.b    #WeapLazer,bull_gun(a2)
  2136.     bne    .bulldead
  2137.     
  2138.     cmp.b    #DEAD,bull_status(a2)
  2139.     beq    .bulldead
  2140. ;    cmp.b    #DYING,bull_status(a2)    ;on his way
  2141. ;    beq    .bulldead
  2142.  
  2143.     ;if bull_life = 0 then the lazer has done enough damage for one da
  2144.     ;bull_Lest has the screen offset to restore!
  2145.     ;bull_cnt has the counter for restoring
  2146.  
  2147.     cmp.b    #0,bull_life(a2)
  2148.     bne    .norest
  2149.     ;fuck, the lazer has finished and watns to be restored!
  2150.     bsr    restlazer
  2151.     bra    .bulldead
  2152. .norest
  2153.     move.l    Bullet1Base,a5
  2154.     clr.l    d1
  2155.     move.w    bull_gfk(a2),d1
  2156.     
  2157.     
  2158.     ;if d1 > 40 then add 40*16*5,a5
  2159. .loopin
  2160.     cmp.b    #40,d1
  2161.     bmi    .ok
  2162.     add.l    #80*16*5,a5
  2163.     sub.l    #40,d1
  2164.     bra    .loopin
  2165. .ok
  2166.     add.l    d1,a5
  2167.  
  2168.  
  2169.     move.l    screen1,a4        ;get coarse
  2170.     add.l    bull_actual(a2),a4
  2171.  
  2172.     move.l    a5,$dff050    ;get mask A
  2173.     move.l    a4,$dff054    ;dst D    screen
  2174.     move.w    #(16*5*64)+1,$dff058
  2175.  
  2176.     PUSHALL
  2177.     CALLGRAF    WaitBlit
  2178.     PULLALL
  2179.  
  2180.     move.l    screen2,a4        ;get coarse
  2181.     add.l    bull_actual(a2),a4
  2182.  
  2183.     move.l    a5,$dff050    ;get mask A
  2184.     move.l    a4,$dff054    ;dst D    screen
  2185.     move.w    #(16*5*64)+1,$dff058
  2186.  
  2187.     PUSHALL
  2188.     CALLGRAF    WaitBlit
  2189.     PULLALL
  2190.  
  2191.     PUSHALL
  2192.     clr.l    d0
  2193.     clr.l    d1
  2194.     move.w    bull_xpos(a2),d0
  2195.     move.w    bull_ypos(a2),d1
  2196.     move.l    LevBase,a0
  2197.     bsr    DestroyPform
  2198.     PULLALL
  2199.  
  2200.  
  2201. .bulldead
  2202.     add.l    #bullet_nd-bullet,a2    ;next bullet
  2203.     dbra    d7,.loop
  2204.  
  2205.     PUSHALL
  2206.     CALLGRAF    WaitBlit
  2207.     PULLALL
  2208.  
  2209.     move.w    #$ffff,$dff044    ;fwm
  2210.     move.w    #$ffff,$dff046    ;lwm
  2211.     move.w    #40-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  2212.     move.w    #scrwid-4,$dff066    ;mod D
  2213.  
  2214.     rts
  2215. restlazer
  2216.     move.l    #0,spare
  2217.     ;DONT TRASH A2 or D7
  2218. ;    move.w    $dff006,d0
  2219. ;    and.l    #$fff,d0
  2220. ;    move.w    d0,$dff180
  2221.  
  2222.     ;source
  2223.     move.l    lazertempBase,a1 *** screen+ whatever for testing ***
  2224.  
  2225.     clr.l    d0
  2226.     move.b    bull_LBnk(a2),d0
  2227.     mulu    #scrwid*16*5,d0
  2228.     add.l    d0,a1
  2229.  
  2230.     move.l    screen1,a0
  2231.     add.l    bull_Lrest(a2),a0    ;that there is the destination
  2232.     ;now get the bullets direction to see if we add or sub 2
  2233.  
  2234.     ;if bullet = right then a0=a0+2
  2235.     ;    add.l    (bull_Lcnt(a2)*2),a1
  2236.  
  2237.     btst    #BOBB_RIGHT,bull_go(a2)
  2238.     beq    .notright
  2239.     ;hes heading to the right!
  2240.     add.w    #16,bull_xpos(a2)
  2241.     add.w    #16,bull_lazx(a2)
  2242.     clr.l    d5
  2243.     move.b    bull_Lcnt(a2),d5
  2244.     add.l    d5,a1
  2245.     add.l    d5,a1
  2246.     add.l    #2,a0
  2247.     add.l    #2,bull_Lrest(a2)
  2248.     
  2249.     add.l    #2,a1
  2250.     
  2251.     move.l    a0,spare
  2252.     
  2253.     move.l    #16-1,d5        ;no lines!
  2254. .copyr1
  2255.     move.w    (a1),(a0)
  2256.     move.w    1*scrwid(a1),1*scrwid(a0)
  2257.     move.w    2*scrwid(a1),2*scrwid(a0)
  2258.     move.w    3*scrwid(a1),3*scrwid(a0)
  2259.     move.w    4*scrwid(a1),4*scrwid(a0)
  2260.     add.l    #scrwid*5,a1
  2261.     add.l    #scrwid*5,a0
  2262.     dbra    d5,.copyr1
  2263.     
  2264.     add.b    #1,bull_Lcnt(a2)
  2265.     cmp.b    #scrwid/2,bull_Lcnt(a2)
  2266.     bne    .notright
  2267.     bsr    kill_bullet
  2268.     
  2269. .notright
  2270.     btst    #BOBB_LEFT,bull_go(a2)
  2271.     beq    .notleft
  2272.     ;hes heading to the leftt!
  2273.     sub.w    #16,bull_xpos(a2)
  2274.     sub.w    #16,bull_lazx2(a2)
  2275.     clr.l    d5
  2276.     move.b    bull_Lcnt(a2),d5
  2277.     add.l    d5,a1
  2278.     add.l    d5,a1
  2279.     add.l    #2,a0
  2280.     sub.l    #2,bull_Lrest(a2)
  2281.     
  2282.     add.l    #2,a1
  2283.     move.l    a0,spare
  2284.  
  2285.     
  2286.     move.l    #16-1,d5        ;no lines!
  2287. .copyl1
  2288.     move.w    (a1),(a0)
  2289.     move.w    1*scrwid(a1),1*scrwid(a0)
  2290.     move.w    2*scrwid(a1),2*scrwid(a0)
  2291.     move.w    3*scrwid(a1),3*scrwid(a0)
  2292.     move.w    4*scrwid(a1),4*scrwid(a0)
  2293.     add.l    #scrwid*5,a1
  2294.     add.l    #scrwid*5,a0
  2295.     dbra    d5,.copyl1
  2296.     
  2297.     sub.b    #1,bull_Lcnt(a2)
  2298.     cmp.b    #-2,bull_Lcnt(a2)
  2299.     bne    .notleft
  2300.     bsr    kill_bullet
  2301. .notleft    
  2302.     ;spare should have the screen address to blit
  2303.     cmp.l    #0,spare
  2304.     beq    .out
  2305.     
  2306.     move.l    spare,a1
  2307.     move.l    spare,a0    ;source
  2308.     sub.l    screen1,a1
  2309.     add.l    screen2,a1    ;dest
  2310.  
  2311.     ;the mintermws have been set up by the print lazer rtn
  2312.  
  2313.     move.w    #scrwid-2,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  2314.     move.w    #scrwid-2,$dff066    ;mod D
  2315.  
  2316.     PUSHALL
  2317.     CALLGRAF    WaitBlit
  2318.     PULLALL
  2319.  
  2320.     move.l    a0,$dff050    ;get mask A
  2321.     move.l    a1,$dff054    ;dst D    screen
  2322.     move.w    #(16*5*64)+1,$dff058
  2323.  
  2324. .out    
  2325.     rts
  2326.  
  2327. DestroyPform
  2328.     ;ok, d0,d1 have x&y in pixies!
  2329.     ;and A0 has the start pointer to the level!
  2330.     
  2331.     sub.w    #1,d0    ;minor frigging
  2332.     sub.w    #1,d1
  2333.     ;now work out map pos
  2334.     clr.l    d2
  2335.     move.w    d0,d2        ;
  2336.     and.l    #$0000fff0,d2    ;kill all orrible bits
  2337.     ror.w    #4,d2        ;shift down
  2338.     and.l    #$0000ffff,d2
  2339.     add.l    d2,a0    ;
  2340.     add.l    d2,a0    ;
  2341.     add.l    d2,a0    ;
  2342.     add.l    d2,a0    ;add map xpos to level
  2343.  
  2344.     move.w    d1,d2        ;
  2345.     and.l    #$0000fff0,d2    ;kill all orrible bits
  2346.     ror.w    #4,d2        ;shift down
  2347.     mulu    #level_wid*4,d2
  2348.     add.l    d2,a0
  2349.     
  2350.     ;this points to a long word on the map
  2351.     ;the forst word is the attr (I think)
  2352.     ;and the 2nd word is the block..
  2353.     ;so zap if youd be so kind, the 2nd word...
  2354.     
  2355.     add.l    #2,a0
  2356.     move.w    #0,(a0)        ;kill it till dead!
  2357.  
  2358.  
  2359.     rts
  2360.  
  2361. go_lazerzone
  2362.     move.l    #bullet_max-1,d7
  2363.  
  2364.     lea    bullet_list,a0
  2365. .loop
  2366.     cmp.b    #WeapLazer,bull_gun(a0)
  2367.     bne    .bulldead
  2368.     
  2369.     cmp.b    #DEAD,bull_status(a0)
  2370.     beq    .bulldead
  2371.     
  2372.     lea    player1,a1
  2373.     move.b    num_players,d6
  2374. .chkplay
  2375.     cmp.b    #DEAD,play_status(a1)    
  2376.     beq    .playdead
  2377.     
  2378. .playdead
  2379.  
  2380.  
  2381. .bulldead
  2382.     add.l    #bullet_nd-bullet,a0    ;next bullet
  2383.     dbra    d7,.loop
  2384.  
  2385.     rts    
  2386.  
  2387. go_grabguns    
  2388.     move.b    #1,PlayerGun
  2389.  
  2390.  
  2391.     move.l    #gun_max-1,d7
  2392.  
  2393.     lea    gun_list,a2        ;point to 1st bullet structure
  2394.     move.l    gun_temp1Base,a4    ;temp storage for grab
  2395.     btst    #1,switch
  2396.     bne    maingrabbull
  2397.     move.l    gun_temp2Base,a4    ;grab/rest place
  2398.     bra    maingrabbull
  2399.  
  2400. go_grabbullets
  2401.  
  2402. ;for the players, change the next 6 numbers to acc.
  2403.  
  2404.  
  2405.     move.l    #bullet_max-1,d7
  2406.  
  2407.     lea    bullet_list,a2        ;point to 1st bullet structure
  2408.     move.l    bullet_temp1Base,a4    ;temp storage for grab
  2409.     btst    #1,switch
  2410.     bne    maingrabbull
  2411.     move.l    bullet_temp2Base,a4    ;grab/rest place
  2412.  
  2413.  
  2414.  
  2415. maingrabbull
  2416. .loop
  2417.     cmp.b    #DEAD,bull_status(a2)
  2418.     beq    .bulldead
  2419. ;    cmp.b    #DYING,bull_status(a2)    ;on his way
  2420. ;    beq    .bulldead
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.     ;do a little loop here to check if the baddy is in a lazerzone!
  2434.     ;dont use :=A2,A4,D0,D1,D2,D7
  2435.     
  2436.     ;if the gun is a lazer then dont check it!!!!!!
  2437.     cmp.b    #WeapLazer,bull_gun(a2)
  2438.     beq    .nolazchk
  2439. ;    bra    .nolazchk
  2440.     
  2441.     
  2442.     move.l    #bullet_max+1,d6
  2443.     
  2444.     lea    bullet_list,a3
  2445. .lazloop
  2446.     cmp.b    #WeapLazer,bull_gun(a3)
  2447.     bne    .deadlazer
  2448.     cmp.w    #0,bull_lazx(a3)
  2449.     bne    .ok1    ;its a lazer
  2450.     cmp.w    #0,bull_lazy(a3)
  2451.     beq    .deadlazer
  2452. .ok1
  2453.     ;ok, its a lazer beam..... do summink!
  2454.     
  2455.     ;if bad_x > bull_lazx AND bad_x2 < bull_lazx then possible kill
  2456.     ;if bad_y > bull_lazy AND bad_y2 < bull_layx then possible kill
  2457.     ;if both of these are TRUE then KILL murder death hurtalot
  2458.     ;    destruction of the poor little baddy!
  2459.     
  2460.     clr.l    d3
  2461.     move.w    bull_xpos(a2),d3
  2462.     
  2463.     cmp.w    bull_lazx(a3),d3
  2464.     blt    .safe
  2465.     cmp.w    bull_lazx2(a3),d3
  2466.     bgt    .safe
  2467.     
  2468.     
  2469.     clr.l    d3
  2470.     move.w    bull_ypos(a2),d3
  2471.     
  2472.     cmp.w    bull_lazy(a3),d3
  2473.     blt    .safe
  2474.     cmp.w    bull_lazy2(a3),d3
  2475.     bgt    .safe
  2476.     ;HAHHHAHAHAHHHHAAX KILL KILL BANG BANG YOUR DEAD KILL KILL
  2477. ;    move.b    #DYING,bull_status(a2)    
  2478.     move.b    #DEAD,bull_status(a2)    
  2479.  
  2480.     move.l    a1,spare
  2481.     move.l    bull_paddr(a2),a1
  2482.     ;if bullet is from the player then dec the players bullet counter..
  2483.     cmp.b    #1,PlayerGun
  2484.     bne    .ok
  2485.     ;its the players bullet...
  2486.     sub.b    #1,play_maxbullscnt(a1)
  2487. .ok
  2488.     move.l    spare,a1
  2489.     
  2490.     bsr    kill_bullet
  2491.  
  2492.     move.w    #$fff,flash
  2493.  
  2494.  
  2495. .safe    
  2496. .deadlazer    add.l    #bullet_nd-bullet,a3    ;next bullet
  2497.     dbra    d6,.lazloop
  2498. .nolazchk
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.     CALLGRAF    WaitBlit
  2524.     move.l    bull_actual(a2),bull_was(a2)
  2525.     clr.l    d0
  2526.     clr.l    d1
  2527.     clr.l    d2
  2528.     move.w    bull_xpos(a2),d0
  2529.     move.w    bull_ypos(a2),d1
  2530.     mulu    #scrwid*5,d1
  2531.  
  2532.     move.w    d0,d2    ;save x
  2533.     and.w    #$000f,d0
  2534.     rol.w    #8,d0
  2535.     rol.w    #4,d0    ;got minterm
  2536.     and.w    #$fff0,d2    ;do corse scrol
  2537.     ror.w    #3,d2
  2538.     add.w    d2,d1    ;got coarse
  2539.     move.l    d1,bull_actual(a2)    ;save coarse scroll
  2540.     move.w    d0,bull_smooth(a2)    ;save smooth    
  2541.     
  2542.     ;if playwas = 0 then copy actual into it
  2543.     cmp.l    #0,bull_was(a2)
  2544.     bne    .okay
  2545.     move.l    bull_actual(a2),bull_was(a2)
  2546. .okay
  2547.  
  2548.     ;if bullet is a Lazer then dont restore it!
  2549.     cmp.b    #WeapLazer,bull_gun(a2)
  2550.     beq    .bulldead
  2551.  
  2552.     add.l    scrbase,d1    
  2553.     move.w    #scrwid-4,$dff064    ;mod A
  2554.     move.w    #4-4,$dff066    ;mod D
  2555.     move.l    d1,$dff050    ;src A
  2556.     move.l    a4,$dff054    ;dst D
  2557.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  2558.     move.w    #(16*5*64)+2,$dff058    ;bltsize 
  2559.  
  2560.     PUSHALL
  2561.     CALLGRAF    WaitBlit
  2562.     PULLALL    
  2563. .bulldead
  2564.     add.l    #16*4*5,a4    ;next grab place please
  2565.     add.l    #bullet_nd-bullet,a2    ;next bullet
  2566.     dbra    d7,.loop
  2567.  
  2568.     move.b    #0,PlayerGun
  2569.  
  2570.     rts
  2571.  
  2572. go_restoreguns
  2573. ;the is for the players gun
  2574.     move.b    #1,PlayerGun
  2575.  
  2576.     move.l    #gun_max-1,d7
  2577.     lea    gun_list,a2    ;bullet structure
  2578.     move.l    gun_temp1Base,a4    ;grabbed space
  2579.     btst    #1,switch
  2580.     bne    mainbull
  2581.     move.l    gun_temp2Base,a4
  2582.     bra    mainbull
  2583.  
  2584.  
  2585. go_restorebullets
  2586. ;origonal idea was
  2587. ;if bull_status = NEW then dont retore yet (as I may not have been setup yet)
  2588. ;    then bull_status = OKAY dont restore.
  2589. ;but afterwards i thought it was not needed.
  2590.  
  2591.  
  2592.  
  2593. ;for the players bullet restore rtn.
  2594. ;copy n change the next 6 lines to work with the gun bits
  2595.  
  2596.  
  2597.  
  2598.     move.l    #bullet_max-1,d7
  2599.     lea    bullet_list,a2    ;bullet structure
  2600.     move.l    bullet_temp1Base,a4    ;grabbed space
  2601.     btst    #1,switch
  2602.     bne    mainbull
  2603.     move.l    bullet_temp2Base,a4
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609. mainbull    
  2610. .loop
  2611.     cmp.b    #DEAD,bull_status(a2)
  2612.     beq    .bulletdead
  2613.  
  2614.     cmp.b    #NEW,bull_status(a2)
  2615.     bne    .notnew
  2616.     move.b    #OKAY,bull_status(a2)
  2617.     bra    .bulletdead
  2618. .notnew
  2619.     cmp.b    #DYING,bull_status(a2)    ;just restore when dying then make DEAD
  2620.     bne    .notdying
  2621. ;    add.b    #1,bull_dedcnt(a2)
  2622. ;    cmp.b    #2,bull_dedcnt(a2)
  2623. ;    bne    .notdying
  2624.     move.b    #DEAD,bull_status(a2)
  2625.  
  2626.     ;if bullet is from the player then dec the players bullet counter..
  2627.     cmp.b    #1,PlayerGun
  2628.     bne    .notdying
  2629.     ;its the players bullet...
  2630.     move.l    a1,RegSave
  2631.     move.l    bull_paddr(a2),a1
  2632.     sub.b    #1,play_maxbullscnt(a1)
  2633.     move.l    RegSave,a1
  2634. .notdying
  2635.     
  2636.     ;if bullet is a Lazer then dont restore it!
  2637.     cmp.b    #WeapLazer,bull_gun(a2)
  2638.     beq    .bulletdead
  2639.     
  2640.  
  2641.  
  2642.     move.l    scrbase,a3
  2643.     add.l    bull_was(a2),a3    ;add coarse
  2644.     ;blit a4 to a3 please
  2645.     
  2646.     move.w    #4-4,$dff064    ;mod A
  2647.     move.w    #scrwid-4,$dff066    ;mod D
  2648.     move.l    a4,$dff050    ;src A
  2649.     move.l    a3,$dff054    ;dst D
  2650.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  2651.     move.w    #(16*5*64)+2,$dff058    ;bltsize 
  2652.     PUSHALL
  2653.     CALLGRAF    WaitBlit
  2654.     PULLALL    
  2655.     
  2656. .bulletdead
  2657.     add.l    #16*5*4,a4        ;next 1 please
  2658.     add.l    #bullet_nd-bullet,a2    ;next bullet
  2659.     dbra    d7,.loop
  2660.  
  2661.     move.b    #0,PlayerGun
  2662.     rts
  2663.  
  2664. kill_bullet
  2665.     ;bullets died. kill him off properly!
  2666.     move.b    #DYING,bull_status(a2)
  2667.     move.b    #0,bull_dedcnt(a2)
  2668.     move.l    a1,spare
  2669.     move.l    bull_paddr(a2),a1
  2670.     bclr    #BOBB_GUN2,bad_doing(a1)
  2671.     move.w    #0,bull_lazx(a1)
  2672.     move.w    #0,bull_lazx2(a1)
  2673.     move.w    #0,bull_lazy(a1)
  2674.     move.w    #0,bull_lazy2(a1)
  2675.  
  2676.     move.l    spare,a1
  2677.  
  2678.  
  2679.  
  2680.     
  2681.     rts
  2682.  
  2683. how_fastx    
  2684.     clr.l    d2
  2685.  
  2686.     cmp.b    #0,bull_waitx(a2)
  2687.     beq    .normal
  2688.     cmp.b    #0,waitflag
  2689.     bne    .hop
  2690.     add.b    #1,bull_waitx(a2)    ;bullet is moving slower than 1pix vblank
  2691. .hop    cmp.b    #0,bull_waitx(a2)
  2692.     bge    .notdone
  2693.     move.l    #1,d2
  2694.     rts
  2695. .notdone
  2696.     move.l    #1,d0    ;END of Waiting. move 1 pixxie please
  2697.     move.l    #0,d2
  2698.     rts
  2699. .normal
  2700.     move.w    bull_life(a2),d1
  2701.     cmp.w    #0,d1
  2702.     bne    .notzero
  2703.  
  2704.     ;if bull_life=0 and gun type is smart then bull_life = ffff
  2705.     cmp.b    #WeapSmart,bull_gun(a2)
  2706.     bne    .notsmart
  2707.     bclr    #BOBB_UP,bull_go(a2)
  2708.     bset    #BOBB_DOWN,bull_go(a2)
  2709.     move.w    #$ffff,bull_life(a2)
  2710.     move.w    #SmartLife,bull_life2(a2)
  2711.     bra    .notzero
  2712. .notsmart
  2713.     ;its zero, so ive run out of puff
  2714.     clr.l    d1
  2715.     move.b    bull_speedx(a2),d1
  2716.     cmp.b    #0,d1
  2717.     bne    .slowme
  2718.  
  2719.     cmp.l    #1,d2
  2720.     bne    .slowing    ;slowing down to change dir
  2721.     ;im turning around
  2722.     bchg    #BOBB_LEFT,bull_go(a2)
  2723.     bchg    #BOBB_RIGHT,bull_go(a2)
  2724.     move.l    #2,d2
  2725.     rts
  2726. .slowing
  2727.     ;bullets died. kill him off properly!
  2728.     
  2729.     ;unless falling to gravity
  2730.     btst    #ATTRB_GRAV,bull_attr(a2)
  2731.     bne    .out    
  2732.     
  2733.     bsr    kill_bullet
  2734. .out    move.l    #2,d2
  2735.     rts
  2736. .slowme
  2737.     ;if bits GRAV or AGRAV are set then just set down!
  2738.     ;        ^^^^
  2739.     btst    #ATTRB_GRAV,bull_attr(a2)
  2740.     beq    .nogravity
  2741.     bset    #BOBB_DOWN,bull_go(a2)
  2742.     bset    #BOBB_DOWN,bull_cango(a2)
  2743.     bset    #BOBB_DOWN,bull_wantgo(a2)
  2744.     move.b    #1,bull_stepx(a2)
  2745.     move.b    #2,bull_stepy(a2)
  2746.     
  2747. .nogravity
  2748.  
  2749.     clr.l    d1
  2750.     move.b    bull_stepx(a2),d1
  2751.     sub.b    d1,bull_speedx(a2)
  2752.     clr.l    d1
  2753.         
  2754.     bra    .over1
  2755. .notzero
  2756.     btst    #ATTRB_SEEKX,bull_attr(a2)    ;if not seek x then .notzero2
  2757.     beq    .notzero2
  2758. ;    cmp.b    #WeapSmart,bull_gun(a2)
  2759. ;    bne    .notzero2
  2760.     clr.l    d0
  2761.     clr.l    d1
  2762.     move.b    bull_wantgo(a2),d0
  2763.     move.b    bull_go(a2),d1
  2764.     and.b    #BOBF_LEFT|BOBF_RIGHT,d0
  2765.     and.b    #BOBF_LEFT|BOBF_RIGHT,d1
  2766.     cmp.b    d0,d1
  2767.     beq    .notzero2
  2768.     ;bull wants to change direction, so slow him down
  2769.     move.l    #1,d2    ;trigger notsmarts slow rtn
  2770.     bra    .notsmart
  2771.     
  2772. .notzero2    
  2773.     clr.l    d1
  2774.     move.b    bull_speedx(a2),d1
  2775.     cmp.b    bull_maxx(a2),d1
  2776.     bge    .over1
  2777.     move.b    bull_stepx(a2),d1
  2778.     add.b    d1,bull_speedx(a2)
  2779. .over1
  2780.     clr.l    d0
  2781.     lea    bull_table,a3
  2782.     move.b    bull_speedx(a2),d1
  2783.     move.b    (a3,d1),d0    
  2784.  
  2785.     btst    #7,d0
  2786.     beq    .positive
  2787.     ;number is negative, so wait a while
  2788.     move.b    d0,bull_waitx(a2)
  2789.     move.l    #2,d2
  2790.     rts
  2791. .positive    
  2792.     move.l    #0,d2
  2793.     rts
  2794.  
  2795. how_fasty
  2796.     clr.l    d2
  2797.  
  2798.     cmp.b    #0,bull_waity(a2)
  2799.     beq    .normal
  2800.     cmp.b    #0,waitflag
  2801.     bne    .hop
  2802.     add.b    #1,bull_waity(a2)    ;bullet is moving slower than 1pix vblank
  2803. .hop    cmp.b    #0,bull_waity(a2)
  2804.     bge    .notdone
  2805.     move.l    #1,d2
  2806.     rts
  2807. .notdone
  2808.     move.l    #1,d0    ;END of Waiting. move 1 pixxie please
  2809.     move.l    #0,d2
  2810.     rts
  2811. .normal
  2812.  
  2813.     move.w    bull_life(a2),d1
  2814.     cmp.w    #0,d1
  2815.     bne    .notzero
  2816.  
  2817.     ;if its a lazer then it doesnt all to gravity!!!!!
  2818.     cmp.b    #WeapLazer,bull_gun(a2)
  2819.     beq    .oopuff
  2820.     
  2821.     btst    #ATTRB_GRAV,bull_attr(a2)
  2822.     beq    .carryon
  2823.     btst    #BOBB_DOWN,bull_go(a2)
  2824.     bne    .notzero2    ;accelerate please
  2825.  
  2826. .carryon    ;if bull_life=0 and gun type is smart then bull_life = ffff
  2827.     cmp.b    #WeapSmart,bull_gun(a2)
  2828.     bne    .notsmart
  2829.     bclr    #BOBB_UP,bull_go(a2)
  2830.     bset    #BOBB_DOWN,bull_go(a2)
  2831.     move.w    #$ffff,bull_life(a2)
  2832.     move.w    #SmartLife,bull_life2(a2)
  2833.     bra    .notzero
  2834. .notsmart
  2835.  
  2836. .oopuff
  2837.     ;its zero, so ive run out of puff
  2838.     clr.l    d1
  2839.     move.b    bull_speedy(a2),d1
  2840.     cmp.b    #0,d1
  2841.     bne    .slowme
  2842.     
  2843.     ;GRAV ive slowed down so now make me go down
  2844.     btst    #ATTRB_GRAV,bull_attr(a2)
  2845.     bne    .change
  2846.     
  2847.     cmp.l    #1,d2
  2848.     bne    .slowing    ;slowing down to change dir
  2849. .change    ;im turning around
  2850.  
  2851.     move.w    #$999,d7
  2852. .llo
  2853.     move.w    #$f00,$dff180
  2854.     dbra    d7,.llo
  2855.     
  2856.     
  2857.     bchg    #BOBB_UP,bull_go(a2)
  2858.     bchg    #BOBB_DOWN,bull_go(a2)    ;falling ....aaaahhh....
  2859.     move.l    #2,d2
  2860.     rts
  2861. .slowing
  2862.     bsr    kill_bullet
  2863.     move.l    #2,d2
  2864.     rts
  2865. .slowme
  2866.     clr.l    d1
  2867.     move.b    bull_stepy(a2),d1
  2868.     sub.b    d1,bull_speedy(a2)
  2869.     clr.l    d1
  2870.         
  2871.     bra    .over1
  2872. .notzero
  2873.     btst    #ATTRB_SEEKY,bull_attr(a2)
  2874.     beq    .notzero2
  2875. ;    cmp.b    #WeapSmart,bull_gun(a2)
  2876. ;    bne    .notzero2
  2877.     clr.l    d0
  2878.     clr.l    d1
  2879.     move.b    bull_wantgo(a2),d0
  2880.     move.b    bull_go(a2),d1
  2881.     and.b    #BOBF_UP|BOBF_DOWN,d0
  2882.     and.b    #BOBF_UP|BOBF_DOWN,d1
  2883.     cmp.b    d0,d1
  2884.     beq    .notzero2
  2885.     ;bull wants to change direction, so slow him down
  2886.     move.l    #1,d2    ;trigger notsmarts slow rtn
  2887.     bra    .notsmart
  2888.     
  2889. .notzero2    
  2890.     clr.l    d1
  2891.     move.b    bull_speedy(a2),d1
  2892.     cmp.b    bull_maxy(a2),d1
  2893.     bge    .over1
  2894.     move.b    bull_stepy(a2),d1
  2895.     add.b    d1,bull_speedy(a2)
  2896. .over1
  2897.     clr.l    d0
  2898.     lea    bull_table,a3
  2899.     move.b    bull_speedy(a2),d1
  2900.     move.b    (a3,d1),d0    
  2901.  
  2902.     btst    #7,d0
  2903.     beq    .positive
  2904.     ;number is negative, so wait a while
  2905.     move.b    d0,bull_waity(a2)
  2906.     move.l    #2,d2
  2907.     rts
  2908. .positive    
  2909.     move.l    #0,d2
  2910.     rts
  2911.     
  2912. go_seek
  2913.     ;only do this rtn if life = ffff
  2914.     cmp.w    #$ffff,bull_life(a2)
  2915.     bne    .out
  2916.  
  2917.     
  2918.     cmp.b    #WeapSmart,bull_gun(a2)
  2919.     bne    .out
  2920.     ;okay if its this weapon then he chasing the player
  2921.     ;so copy players x/y into seekx/y
  2922.     
  2923.     ;find player structure please
  2924.     lea    player1,a1
  2925.     clr.l    d6
  2926.     move.b    bull_player(a2),d6
  2927.     
  2928.     ;if the player im seeking is DEAD  then kill me off!
  2929.     
  2930.     ;re-write this rtn to make bullets fall to gravity (out of puff)
  2931.     lea    liveplayers,a3
  2932.     ;if liveplayer = fe or ff then kill bullet off (player DEAD)
  2933.     cmp.b    #$fe,(a3,d6)
  2934.     bne    .okay1
  2935. ;    move.b    #DEAD,bull_status(a2)    ;kill bullet off again
  2936.  
  2937.     move.b    #WeapNorm,bull_gun(a2)    ;turn into normal bullet
  2938.     
  2939.     move.b    #0,bull_attr(A2)        ;clear me
  2940.     bset    #ATTRB_EDGE,bull_attr(A2)    ;bounce off edges
  2941.     bset    #ATTRB_GRAV,bull_attr(A2)    ;fall when out of puff
  2942.     bset    #KBULB_BOTTOM,bull_death(a2)    ;die when on bottom of screen
  2943.  
  2944.     bclr    #BOBB_UP,bull_go(a2)
  2945.     bclr    #BOBB_UP,bull_wantgo(a2)
  2946.     bset    #BOBB_DOWN,bull_go(a2)
  2947.     bset    #BOBB_DOWN,bull_wantgo(a2)
  2948.  
  2949.  
  2950. .not_norm1
  2951.  
  2952. .okay1    
  2953.  
  2954. .loop
  2955.     cmp.b    #0,d6
  2956.     beq    .got_struct
  2957.  
  2958.     add.l    #player1_nd-player1,a1    ;next player please
  2959.     dbra    d6,.loop
  2960. .got_struct
  2961.     move.w    play_xpos(a1),bull_seekx(a2)
  2962.     move.w    play_ypos(a1),bull_seeky(a2)
  2963.     add.w    #0,bull_seekx(a2)    ;half way through
  2964.     add.w    #6,bull_seeky(a2)    ;half way through
  2965.         
  2966.     
  2967.     clr.l    d0
  2968.     clr.l    d1
  2969.     move.w    bull_seekx(a2),d0
  2970.     cmp.w    bull_xpos(a2),d0
  2971.     beq    .checkud
  2972.     bgt    .lower
  2973.     ;its to the right
  2974.     bclr    #BOBB_RIGHT,bull_wantgo(a2)
  2975.     bset    #BOBB_LEFT,bull_wantgo(a2)
  2976.     bra    .checkud
  2977. .lower
  2978.     bclr    #BOBB_LEFT,bull_wantgo(a2)
  2979.     bset    #BOBB_RIGHT,bull_wantgo(a2)
  2980. .checkud
  2981.     clr.l    d0
  2982.     clr.l    d1
  2983.     move.w    bull_seeky(a2),d0
  2984.     cmp.w    bull_ypos(a2),d0
  2985.     beq    .out
  2986.     bgt    .lowerd
  2987.     ;its to the up
  2988.     bclr    #BOBB_DOWN,bull_wantgo(a2)
  2989.     bset    #BOBB_UP,bull_wantgo(a2)
  2990.  
  2991.  
  2992.     bra    .out
  2993. .lowerd
  2994.     bclr    #BOBB_UP,bull_wantgo(a2)
  2995.     bset    #BOBB_DOWN,bull_wantgo(a2)
  2996.  
  2997. .out    rts
  2998.  
  2999. moving_bulls
  3000.     move.b    #0,waitflag
  3001.     bsr    go_seek
  3002.     ;if life = 0 then bullet has run out of puff. slow it down
  3003.     clr.l    d1
  3004.     move.w    bull_life(a2),d1
  3005.     cmp.w    #$ffff,d1
  3006.     beq    .onwards    ;infinite energy
  3007.     cmp.w    #0,d1
  3008.     beq    .onwards
  3009.     sub.w    #1,bull_life(a2)
  3010.  
  3011. .onwards    
  3012.     cmp.w    #0,d1
  3013.     bne    .loadsapuff
  3014.     ;no puff
  3015.     bclr    #BOBB_UP,bull_go(a2)
  3016.     bset    #BOBB_DOWN,bull_go(a2)
  3017. .loadsapuff
  3018.     cmp.b    #WeapSmart,bull_gun(a2)
  3019.     bne    .notsmart
  3020.     cmp.w    #$ffff,bull_life(a2)
  3021.     bne    .notsmart
  3022.     ;its a smart bullet, so sub from bull life2
  3023.     cmp.b    #0,bull_life2(a2)
  3024.     bne    .onagain
  3025.     ;kill off bullet!
  3026. ;    move.w    #0,bull_life(a2)    ;make normal dead bullet!
  3027.     bclr    #BOBB_UP,bull_wantgo(a2)
  3028.     bset    #BOBB_DOWN,bull_wantgo(a2)
  3029.     move.b    #WeapNorm,bull_gun(a2)
  3030.     bra    .notsmart
  3031. .onagain
  3032.     sub.w    #1,bull_life2(a2)
  3033. .notsmart
  3034.  
  3035.  
  3036.     btst    #BOBB_RIGHT,bull_go(a2)
  3037.     beq    .not_right
  3038.     ;bullets going to the right!
  3039.  
  3040.  
  3041.     bsr    how_fastx    
  3042.     ;if d2=2 then bra notleftright
  3043.     ;if d2=0 then all is groovy
  3044.     ;if d2=1 then bra .not_right
  3045.     ;d0 will have speed increment (if d2=0)
  3046.     cmp.l    #2,d2
  3047.     beq    .not_leftright
  3048.     cmp.l    #1,d2
  3049.     beq    .not_right
  3050.  
  3051.     cmp.b    #WeapLazer,bull_gun(a2)
  3052.     bne    .notlazer
  3053.     ;if its a lazer then do not use acc.
  3054.     ;move in 16 pixies!
  3055.     move.l    #16,d0
  3056.     move.b    d0,bull_speedx(a2)
  3057.     
  3058. .notlazer
  3059.     add.w    d0,bull_xpos(a2)
  3060.     
  3061.     cmp.w    #320+16,bull_xpos(a2)
  3062.     blt    .ok
  3063.     
  3064.     bsr    is_edger
  3065.     tst.l    d2
  3066.     bne    .ok
  3067.         
  3068.     sub.w    #320+16,bull_xpos(a2)
  3069. .ok
  3070.     ;if its a lazer then store the value in lazercoll(a2)
  3071.     ;store it in bull_lazx2
  3072.     move.w    bull_xpos(a2),bull_lazx2(a2)
  3073.  
  3074.  
  3075. .not_right
  3076.     btst    #BOBB_LEFT,bull_go(a2)
  3077.     beq    .not_left
  3078.     ;bullets going to the left!
  3079.  
  3080.     bsr    how_fastx    
  3081.     ;if d2=2 then bra notleftright
  3082.     ;if d2=0 then all is groovy
  3083.     ;if d2=1 then bra .not_right
  3084.     ;d0 will have speed increment (if d2=0)
  3085.     cmp.l    #2,d2
  3086.     beq    .not_leftright
  3087.     cmp.l    #1,d2
  3088.     beq    .not_left
  3089.  
  3090.     cmp.b    #WeapLazer,bull_gun(a2)
  3091.     bne    .notlazerl
  3092.     ;if its a lazer then do not use acc.
  3093.     ;move in 16 pixies!
  3094.     move.l    #16,d0
  3095.     move.b    d0,bull_speedx(a2)
  3096.     
  3097. .notlazerl
  3098.         
  3099.     sub.w    d0,bull_xpos(a2)
  3100.     
  3101.     cmp.w    #0,bull_xpos(a2)
  3102.     bgt    .okl
  3103.     
  3104.     bsr    is_edger
  3105.     tst.l    d2
  3106.     bne    .okl
  3107.  
  3108.     add.w    #320+16,bull_xpos(a2)
  3109. .okl
  3110.     ;if its a lazer then store the value in lazercoll(a2)
  3111.     ;store it in bull_lazx
  3112.     move.w    bull_xpos(a2),bull_lazx(a2)
  3113.  
  3114. .not_left
  3115.  
  3116.  
  3117. .not_leftright
  3118.     ;if Agrav is set then the bullet wants to fall all the time!
  3119.     btst    #ATTRB_AGRAV,bull_attr(a2)
  3120.     bne    .jumpy
  3121.     
  3122.     ;if grav is set and bull_life = 0 FALL
  3123.     btst    #ATTRB_GRAV,bull_attr(a2)
  3124.     beq    .notgrav
  3125.     btst    #BOBB_DOWN,bull_go(a2)
  3126.     cmp.w    #0,bull_life(a2)
  3127.     bne    .notgrav
  3128.     ;okay he wants to fall!!!!!!
  3129.     bset    #BOBB_DOWN,bull_wantgo(a2)
  3130.     bra    .jumpy
  3131.     
  3132.  
  3133. .notgrav    btst    #BOBB_DOWN,bull_go(a2)
  3134.     beq    .not_down
  3135.     ;bullets going down!
  3136.  
  3137. .jumpy
  3138.     cmp.b    #1,PlayerGun
  3139.     bne    .noonon
  3140. ;    bsr    JIM
  3141. .noonon
  3142.     bsr    how_fasty    
  3143.     ;if d2=2 then bra notupdown
  3144.     ;if d2=0 then all is groovy
  3145.     ;if d2=1 then bra .not_down
  3146.     ;d0 will have speed increment (if d2=0)
  3147.     cmp.l    #2,d2
  3148.     beq    .not_updown
  3149.     cmp.l    #1,d2
  3150.     beq    .not_down
  3151.  
  3152.     ;if bull_ypos+d0 goes over a 16 boundary AND
  3153.     ;bull_attr = BFORM 
  3154.     ;then check to see if its hit a platform
  3155.     ;if it has then make it bounce!!!
  3156.     ;just flip bull_go UP/DOWN.
  3157.     ;hopefully the program will sort this out!
  3158.     
  3159.     move.w    bull_ypos(a2),d1
  3160.     and.l    #%11110000,d1
  3161.  
  3162.     add.w    d0,bull_ypos(a2)
  3163.     
  3164.     move.w    bull_ypos(a2),d3
  3165.     and.l    #%11110000,d3
  3166.     cmp.w    d1,d3
  3167.     beq    .noPcheck    ;no platform check
  3168.     ;okay, weve omoved over a bonudary.
  3169.     ;lets check to see if hes hit a platorm!
  3170.     ;if hes attr = bform anyway!
  3171.     btst    #ATTRB_BFORM,bull_attr(a2)
  3172.     beq    .noPcheck
  3173.     
  3174.     ;if there is a character here (or possibly under here) then he
  3175.     ;should bounce up again!
  3176.     ;checking platform!
  3177.     move.l    #$994,d3
  3178. .wait
  3179. ;    move.w    #$0f0,$dff180
  3180.     dbra    d3,.wait
  3181.     
  3182.     ;now work out map pos
  3183.     clr.l    d0
  3184.     move.w    bull_xpos(a2),d0
  3185.     and.l    #$0000fff0,d0    ;kill all orrible bits
  3186.     ror.w    #4,d0        ;shift down
  3187.     move.b    d0,bull_mapx(a2)        ;save baddy mapx
  3188.  
  3189.     clr.l    d0
  3190.     move.w    bull_ypos(a2),d0
  3191.     and.l    #$0000fff0,d0    ;kill all orrible bits
  3192.     ror.w    #4,d0        ;shift down
  3193.     move.b    d0,bull_mapy(a2)        ;save baddy mapy
  3194.  
  3195.     clr.l    d0
  3196.     clr.l    d1
  3197.     move.b    bull_mapx(a2),d0
  3198.     move.b    bull_mapy(a2),d1
  3199.  
  3200.     add.b    #1,d1    ;check under foot
  3201.  
  3202.     move.l    a2,spare        ;*
  3203.     bsr    find_char        ;findchar uses a2 (bad news)
  3204.  
  3205.     lea    walk_on,a2        ;what chars can you walk on
  3206. .underneath
  3207.     cmp.b    #0,(a2)
  3208.     beq    .still_falling
  3209.     cmp.b    (a2)+,d0
  3210.     beq    .found_platform
  3211.     bra    .underneath
  3212. .found_platform
  3213.     move.l    spare,a2        ;*
  3214.     
  3215.     ;set bullgo to UP!
  3216.     bclr    #BOBB_DOWN,bull_go(a2)
  3217.     bset    #BOBB_UP,bull_go(a2)
  3218.  
  3219.     bclr    #BOBB_UP,bull_wantgo(a2)
  3220.     bset    #BOBB_DOWN,bull_wantgo(a2)
  3221.     
  3222. ;    move.b    bull_go(a2),d0
  3223. ;    move.b    bull_wantgo(a2),d0
  3224.  
  3225.  
  3226. .still_falling
  3227.     move.l    spare,a2        ;*
  3228.     
  3229.     
  3230.     
  3231.     
  3232.     
  3233.     
  3234.     
  3235.     
  3236.     
  3237.     
  3238. .noPcheck
  3239.     
  3240.     cmp.w    #256+16,bull_ypos(a2)
  3241.     blt    .okd
  3242.     
  3243.     btst    #KBULB_BOTTOM,bull_death(a2)
  3244.     beq    .safebottom
  3245.     bsr    kill_bullet
  3246.     bra    .okd
  3247. .safebottom
  3248.     sub.w    #256+16,bull_ypos(a2)
  3249. .okd
  3250.  
  3251. .not_down
  3252.  
  3253.  
  3254.     btst    #BOBB_UP,bull_go(a2)
  3255.     beq    .not_up
  3256.     ;bullets going to the up!
  3257.  
  3258.     bsr    how_fasty
  3259.     ;if d2=2 then bra notupdown
  3260.     ;if d2=0 then all is groovy
  3261.     ;if d2=1 then bra .not_up
  3262.     ;d0 will have speed increment (if d2=0)
  3263.     cmp.l    #2,d2
  3264.     beq    .not_updown
  3265.     cmp.l    #1,d2
  3266.     beq    .not_up
  3267.         
  3268.     sub.w    d0,bull_ypos(a2)
  3269.     
  3270.     cmp.w    #0,bull_ypos(a2)
  3271.     bgt    .oku
  3272.     add.w    #256+16,bull_ypos(a2)
  3273. .oku
  3274.  
  3275. .not_up
  3276.  
  3277.  
  3278. .not_updown
  3279.  
  3280. .out    rts
  3281. JIM
  3282.     move.b    bull_go(a2),d0
  3283.     move.b    bull_wantgo(a2),d0
  3284.     rts
  3285.  
  3286. is_edger
  3287.     clr.l    d2
  3288.     ;if its the lazer at the edge then start it from the cannnon again
  3289.     ;(this clears up any baddy residue) (NO)
  3290.     ;it makes it harder for the lazer collision rtn!
  3291.     cmp.b    #WeapLazer,bull_gun(a2)
  3292.     bne    .nolazer
  3293.     ;bull_paddr will have the structure of the firer
  3294. ;    bclr    #BOBB_LEFT|BOBB_RIGHT,bull_go(a2)
  3295. ;    bclr    #BOBB_LEFT|BOBB_RIGHT,bull_wantgo(a2)
  3296.     move.l    #1,d2    ;dont do anything
  3297.     
  3298.     ;if lazer going right then sub 16
  3299.     ;if lazer gonig left then add 16
  3300.     
  3301.     btst    #BOBB_LEFT,bull_go(a2)
  3302.     beq    .notleft
  3303.     add.w    #16,bull_xpos(a2)
  3304. .notleft
  3305.     btst    #BOBB_RIGHT,bull_go(a2)
  3306.     beq    .notright
  3307.     sub.w    #16,bull_xpos(a2)
  3308. .notright
  3309.     
  3310.     rts
  3311.     
  3312. .nolazer
  3313.     clr.l    d2
  3314.     
  3315.     ;if ive hit the edge and ATTR=EDGE then bounce it off
  3316.     btst    #ATTRB_EDGE,bull_attr(a2)
  3317.     beq    .not_edger
  3318.     ;hit edge of screen...
  3319.     ;so instant change direction
  3320.     ;And Half the speed
  3321.     bchg    #BOBB_LEFT,bull_go(a2)    ;change direction
  3322.     bchg    #BOBB_RIGHT,bull_go(a2)
  3323.     clr.l    d0        ;half the speed
  3324.     move.b    bull_speedx(a2),d0
  3325.     sub.b    #4,d0
  3326.     bgt    .kik
  3327.     move.b    #0,d0
  3328. .kik    move.b    d0,bull_speedx(a2)
  3329.     move.l    #1,d2    ;dont do anything
  3330. .not_edger
  3331.     ;if ive hit the edge of the screen and kbul = edge then die!!!
  3332.     btst    #KBULB_EDGE,bull_death(a2)
  3333.     bne    .nodedger
  3334.     bsr    kill_bullet
  3335. .nodedger
  3336.     rts
  3337.  
  3338. go_moveguns
  3339. ;move guns is for the player, and move bullets is for the baddies bullets
  3340.     move.b    #1,PlayerGun
  3341.  
  3342.     lea    gun_list,a2
  3343.     move.l    #gun_max-1,d7
  3344.     bra    mainmovegun
  3345.     
  3346. go_movebullets
  3347.  
  3348. ;for the players, just change the next 2 lines to acc.
  3349.  
  3350.     lea    bullet_list,a2
  3351.     move.l    #bullet_max-1,d7
  3352.     
  3353.     
  3354. mainmovegun    
  3355. .loop
  3356.     cmp.b    #DEAD,bull_status(a2)
  3357.     beq    .notnew
  3358.  
  3359. ;    move.w    $dff006,$dff180
  3360.     bsr    moving_bulls
  3361.     
  3362. .notnew
  3363.     add.l    #bullet_nd-bullet,a2    ;next player
  3364.     dbra    d7,.loop
  3365.  
  3366.     move.b    #0,PlayerGun
  3367.     rts
  3368.  
  3369. go_shoot    ;Can we fire, if so shall we??
  3370.     clr.l    d7
  3371.     move.b    random,d7
  3372.     cmp.b    bad_randg(a1),d7    ;random seeky fire
  3373.     bne    .out
  3374.     ;okay random wants to fire!
  3375.     ;can the baddy do it?
  3376.     btst    #BOBB_GUN2,bad_ability(a1)
  3377.     beq    .out        ;hey, i cant shoot
  3378.     ;am i already shooting?
  3379.     btst    #BOBB_GUN2,bad_doing(a1)
  3380.     bne    .out        ;already shooting so do setup again
  3381.     ;okay, baddy can fire if he wants to
  3382.     ;lets see if weve got any spare bullet bobs!
  3383.     lea    bullet_list,a2
  3384.     move.l    #bullet_max-1,d7
  3385. .loop
  3386.     ;find a dead bullet (status = DEAD)
  3387.     cmp.b    #DEAD,bull_status(a2)
  3388.     bne    .not_dead
  3389.     ;okay, weve found a bullet. Now lets get it up and running
  3390.  
  3391.     ;clear structure for new baddy
  3392.     move.l    a2,a3
  3393.     move.l    #bullet_nd-bullet-1,d6    
  3394. .blank    move.b    #0,(a3)+
  3395.     dbra    d6,.blank
  3396.  
  3397.     bset    #BOBB_GUN2,bad_doing(a1)
  3398.     move.b    bad_gun(a1),bull_gun(a2)    ;copy weapon type
  3399.     move.b    bad_power(a1),bull_power(a2)    ;bullet power
  3400.  
  3401.     bsr    Prep_bullet
  3402.  
  3403.     move.w    bad_gungfk(a1),bull_gfk(a2)
  3404.  
  3405.     bsr    bullet_setup
  3406.  
  3407.         
  3408. ;    add.b    #1,random
  3409.     
  3410.     bra    .out
  3411. .not_dead
  3412.     add.l    #bullet_nd-bullet,a2    ;next bullet
  3413.     dbra    d7,.loop
  3414.  
  3415. .out    rts
  3416.  
  3417. bullet_setup
  3418.     cmp.b    #WeapSmart,bull_gun(a2)
  3419.     bne    .not_smart1
  3420. ;    move.w    #24,bull_gfk(a2)
  3421.     bset    #ATTRB_SEEKX,bull_attr(A2)
  3422.     bset    #ATTRB_SEEKY,bull_attr(A2)
  3423.     bset    #KBULB_BOTTOM,bull_death(a2)    ;** TEST ** die when on bottom of screen
  3424.     bset    #ATTRB_EDGE,bull_attr(A2)    ;** TEST ** bounce off edges
  3425. .not_smart1
  3426.  
  3427.     cmp.b    #WeapNorm,bull_gun(a2)
  3428.     bne    .not_norm1
  3429. ;    move.w    #28,bull_gfk(a2)
  3430. ;    bset    #ATTRB_EDGE,bull_attr(A2)    ;bounce off edges
  3431.     bset    #ATTRB_GRAV,bull_attr(A2)    ;fall when out of puff
  3432.     bset    #KBULB_BOTTOM,bull_death(a2)    ;die when on bottom of screen
  3433.     ;the normal baddy may not be moving l/r 
  3434.     ;so look at cango to decide which way to shoot!
  3435. .not_norm1
  3436.     cmp.b    #WeapLazer,bull_gun(a2)
  3437.     bne    .not_Lazer1
  3438.     move.w    #160,bull_gfk(a2)
  3439.     bset    #ATTRB_GRAV,bull_attr(A2)    ;fall when out of puff
  3440.     bset    #KBULB_BOTTOM,bull_death(a2)    ;die when on bottom of screen
  3441.     move.b    bad_LBnk(a1),bull_LBnk(a2)    ;copy restore bank no. across
  3442.     ;copy restore starting position!
  3443.     move.b    bad_mapx(a1),bull_Lcnt(a2)    ;copy start
  3444.     move.l    bad_actual(a1),bull_Lrest(a2)    ;copy scr pos
  3445.     move.w    #$120,bull_life(a2)
  3446.     move.w    bad_x(a1),bull_lazx(a2)
  3447.     move.w    bad_x(a1),bull_lazx2(a2)
  3448.     add.w    #16,bull_lazx2(a2)
  3449.     move.w    bad_y(a1),bull_lazy(a2)
  3450.     move.w    bad_y(a1),bull_lazy2(a2)
  3451.     add.w    #16,bull_lazy2(a2)
  3452. .not_Lazer1
  3453.  
  3454.     ;if its a weap bounce then youve got to set some bounce bits
  3455.     ;and setup some flags    
  3456.     
  3457.     cmp.b    #WeapBounce,bull_gun(a2)
  3458.     bne    .notbouncey
  3459. ;    move.w    #$f00,$dff180
  3460.     ;    EDGE,BFORM,AGRAV
  3461.     move.w    #96,bull_gfk(a2)
  3462.     bset    #ATTRB_GRAV,bull_attr(a2)    ;fall when out of puff
  3463.     bset    #ATTRB_AGRAV,bull_attr(a2)    ;fall always
  3464.     bset    #ATTRB_EDGE,bull_attr(A2)    ;bounce on edge of scr
  3465.     bset    #ATTRB_BFORM,bull_attr(A2)    ;bounce on pform
  3466.     bset    #BOBB_DOWN,bull_go(a2)
  3467.     bset    #BOBB_DOWN,bull_wantgo(a2)
  3468.     bclr    #BOBB_UP,bull_go(a2)
  3469.     bclr    #BOBB_UP,bull_wantgo(a2)
  3470.     
  3471.     
  3472. .notbouncey
  3473.     
  3474.     ;put all other bullet setups here
  3475.     rts
  3476.     
  3477. Prep_bullet
  3478.     move.l    a1,bull_paddr(a2)
  3479.  
  3480.     ;setup for smart bullet!
  3481.  
  3482.     move.w    bad_y(a1),bull_ypos(a2)
  3483.     
  3484.     clr.l    d0
  3485.     move.w    bad_x(a1),d0
  3486.     ;if baddy facing left and xpos over 16 then
  3487.  
  3488.     ;the weapnorm/weaplazer baddy may not be moving l/r 
  3489.     ;so look at cango to decide which way to shoot!
  3490.     cmp.b    #WeapLazer,bull_gun(a2)
  3491.     beq    .in
  3492.     cmp.b    #WeapNorm,bull_gun(a2)
  3493.     bne    .okl
  3494. .in    btst    #BOBB_LEFT,bad_cango(a1)    ;check baddy
  3495.     beq    .not_left
  3496.     bra    .normjumpl
  3497.  
  3498. .okl
  3499.  
  3500.     btst    #BOBB_LEFT,bad_go(a1)    ;check baddy
  3501.     beq    .not_left
  3502.  
  3503. .normjumpl    ;okay, hes facing left. Is his xpos over 16?
  3504.     cmp.w    #16,bad_x(a1)
  3505.     bgt    .okayl
  3506.     ;on very edge of screen, so kill me off
  3507.     move.b    #DEAD,bull_status(a2)    ;kill bullet off again
  3508.     
  3509.     ;if bullet is from the player then dec the players bullet counter..
  3510.     cmp.b    #1,PlayerGun
  3511.     bne    .okayl
  3512.     ;its the players bullet...
  3513.     move.l    a1,RegSave
  3514.     move.l    bull_paddr(a2),a1
  3515.     sub.b    #1,play_maxbullscnt(a1)
  3516.     move.l    RegSave,a1
  3517.  
  3518. .okayl
  3519.     ;okay its safe to do so
  3520.     sub.w    #16,d0
  3521.     move.w    d0,bull_xpos(a2)
  3522.     bset    #BOBB_LEFT,bull_go(a2)
  3523.     bset    #BOBB_LEFT,bull_wantgo(a2)
  3524. .not_left
  3525.  
  3526.  
  3527.     ;the weapnorm/weaplazer baddy may not be moving l/r 
  3528.     ;so look at cango to decide which way to shoot!
  3529.     cmp.b    #WeapLazer,bull_gun(a2)
  3530.     beq    .in2
  3531.     cmp.b    #WeapNorm,bull_gun(a2)
  3532.     bne    .okr
  3533. .in2    btst    #BOBB_RIGHT,bad_cango(a1)    ;check baddy
  3534.     beq    .not_right
  3535.     bra    .normjumpr
  3536.  
  3537. .okr
  3538.  
  3539.     ;if baddy facing right and xpos under 320+16-16 then
  3540.     btst    #BOBB_RIGHT,bad_go(a1)    ;check baddy
  3541.     beq    .not_right
  3542. .normjumpr    ;okay, hes facing right. Is his xpos over 320+16-16?
  3543.     cmp.w    #320+16-16,bad_x(a1)    ;edge of screen?
  3544.     blt    .okayr
  3545.     ;on very edge of screen, so kill me off
  3546.     move.b    #DEAD,bull_status(a2)    ;kill bullet off again
  3547.     
  3548.     ;if bullet is from the player then dec the players bullet counter..
  3549.     cmp.b    #1,PlayerGun
  3550.     bne    .okayr
  3551.     ;its the players bullet...
  3552.     move.l    a1,RegSave
  3553.     move.l    bull_paddr(a2),a1
  3554.     sub.b    #1,play_maxbullscnt(a1)
  3555.     move.l    RegSave,a1
  3556.  
  3557. .okayr
  3558.     ;okay its safe to do so
  3559.     add.w    #16,d0
  3560.     move.w    d0,bull_xpos(a2)
  3561.     bset    #BOBB_RIGHT,bull_go(a2)
  3562.     bset    #BOBB_RIGHT,bull_wantgo(a2)
  3563. .not_right
  3564.  
  3565.  
  3566. prepbull2
  3567.     move.b    #NEW,bull_status(a2)    ;come to life please
  3568.     ;****SORT OUT the mapx/y positions****
  3569.     
  3570.     move.b    #0,bull_speedx(a2)    ;current bullet speed pos
  3571.     move.b    #0,bull_speedy(a2)
  3572.     move.b    #60,bull_maxx(a2)    ;max in speed table
  3573.     move.b    #60,bull_maxy(a2)
  3574.     move.b    #4,bull_stepx(a2)    ;step through table
  3575.     move.b    #6,bull_stepy(a2)    ;step through table
  3576.         ;i.e. to increase speed. bull_speedx+bull_stepx
  3577.     move.w    #$40,bull_life(a2)    ;life = ffff (unlimited)
  3578.     move.w    #100,bull_seekx(a2)    ;seek here pleasex
  3579.     move.w    #130,bull_seeky(a2)    ;seek here pleasey
  3580.     move.b    #0,bull_waitx(a2)
  3581.     move.b    #0,bull_waity(a2)
  3582.     move.b    #0,bull_attr(a2)
  3583.     move.b    #0,bull_death(a2)
  3584.     
  3585.     
  3586.     cmp.b    #1,PlayerGun
  3587.     beq    .okay
  3588.     
  3589.     ;this bit has to be re-written to grab a rnd player to chase
  3590.     lea    player1,a3
  3591.     clr.l    d0
  3592.     move.b    randplay,d0
  3593. .loop    
  3594.     cmp.b    #0,d0
  3595.     beq    .gotim
  3596.     add.l    #player1_nd-player1,a3    ;next player
  3597.     sub.b    #1,d0
  3598.     bra    .loop
  3599. .gotim
  3600.     cmp.b    #DEAD,play_status(a3)    ;is player dead
  3601.     bne    .okay
  3602.     move.b    #DEAD,bull_status(a2)    ;kill bullet off again
  3603. .okay
  3604.     
  3605.     
  3606. .not_firing
  3607.     rts
  3608.  
  3609. anim_baddy
  3610.     lea    bad_an_rcnt(a1),a2
  3611.     clr.l    d0
  3612.     move.b    bad_an_off(a1),d0
  3613.     add.l    d0,a2
  3614.     move.b    (a2),d0
  3615.     
  3616.     add.b    #1,bad_anim(a1)
  3617.     cmp.b    bad_anim(a1),d0
  3618.     bgt    .fine2
  3619.     ;at end of animation frames
  3620.     move.b    #0,bad_anim(a1)    ;reset it
  3621. .fine2
  3622.     rts
  3623.  
  3624. find_char    
  3625.     and.l    #$000000ff,d0
  3626.     and.l    #$000000ff,d1
  3627.     sub.l    #1,d0    ;go left a char!
  3628.     sub.l    #1,d1    ;go up a char!
  3629.     move.l    LevBase,a2
  3630.     mulu    #level_wid*4,d1
  3631.     add.l    d1,a2
  3632.     add.l    d0,a2
  3633.     add.l    d0,a2
  3634.     add.l    d0,a2
  3635.     add.l    d0,a2
  3636.     
  3637.     move.l    (a2),d0    ;get char under baddy
  3638.     and.l    #$0000ffff,d0    ;kill attr
  3639.     rts
  3640.  
  3641. go_restoreplayer1
  3642.     clr.l    d7
  3643.     move.b    num_players,d7
  3644.     sub.l    #1,d7    ;for dbra
  3645.     lea    player1,a1        ;players structure
  3646.     move.l    player_temp1Base,a2    ;grabbed space
  3647.     btst    #1,switch
  3648.     bne    .loop
  3649.     move.l    player_temp2Base,a2
  3650.     
  3651. .loop
  3652.     ;is player dead. if so skip it
  3653.     cmp.b    #DEAD,play_status(a1)    
  3654.     beq    .dead
  3655.     
  3656.     ;is player dying then restore and then make him DEAD
  3657.     cmp.b    #DYING,play_status(a1)    
  3658.     bne    .nodie
  3659.     add.b    #1,play_dedcnt(a1)
  3660.     cmp.b    #2,play_dedcnt(a1)
  3661.     bne    .nodie
  3662.     move.b    #DEAD,play_status(a1)
  3663. .nodie
  3664.     
  3665.     move.l    scrbase,a3
  3666.     add.l    play_was(a1),a3    ;add coarse
  3667.     ;blit a2 to a3 please
  3668.     
  3669.     CALLGRAF    WaitBlit
  3670.     move.w    #4-4,$dff064    ;mod A
  3671.     move.w    #scrwid-4,$dff066    ;mod D
  3672.     move.l    a2,$dff050    ;src A
  3673.     move.l    a3,$dff054    ;dst D
  3674.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  3675.     move.w    #(24*5*64)+2,$dff058    ;bltsize 
  3676.  
  3677. .dead    
  3678.     add.l    #24*5*4,a2        ;next 1 please
  3679.     add.l    #player1_nd-player1,a1    ;next player
  3680.     dbra    d7,.loop
  3681.     
  3682.     rts
  3683.     
  3684. go_grabplayer1
  3685.     clr.l    d7
  3686.     move.b    num_players,d7
  3687.     sub.l    #1,d7    ;for dbra
  3688.  
  3689.     lea    player1,a1        ;point to 1st player structure
  3690.     move.l    player_temp1Base,a4    ;temp storage for grab
  3691.     btst    #1,switch
  3692.     bne    .loop
  3693.     move.l    player_temp2Base,a4    ;grab/rest place
  3694. .loop
  3695.     ;is player dead. if so skip it
  3696.     cmp.b    #DEAD,play_status(a1)    
  3697.     beq    .dead
  3698.     ;or dying
  3699. ;    cmp.b    #DYING,play_status(a1)    
  3700. ;    beq    .dead
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.     ;do a little loop here to check if the baddy is in a lazerzone!
  3707.     ;dont use :=A1,A4,D0,D1,D2,D7
  3708.     
  3709.     move.l    #bullet_max+1,d6
  3710.     
  3711.     lea    bullet_list,a2
  3712. .lazloop
  3713.     cmp.b    #WeapLazer,bull_gun(a2)
  3714.     bne    .deadlazer
  3715.     cmp.w    #0,bull_lazx(a2)
  3716.     bne    .ok1    ;its a lazer
  3717.     cmp.w    #0,bull_lazy(a2)
  3718.     beq    .deadlazer
  3719. .ok1
  3720.     ;ok, its a lazer beam..... do summink!
  3721.     
  3722.     ;if play_xpos > bull_lazx AND play_x2 < bull_lazx then possible kill
  3723.     ;if play_ypos > bull_lazy AND play_y2 < bull_layx then possible kill
  3724.     ;if both of these are TRUE then KILL murder death hurtalot
  3725.     ;    destruction of the poor little player!
  3726.     
  3727.     clr.l    d3
  3728.     move.w    play_xpos(a1),d3
  3729.     
  3730.     cmp.w    bull_lazx(a2),d3
  3731.     blt    .safe
  3732.     cmp.w    bull_lazx2(a2),d3
  3733.     bgt    .safe
  3734.     
  3735.     
  3736.     clr.l    d3
  3737.     move.w    play_ypos(a1),d3
  3738.     
  3739.     cmp.w    bull_lazy(a2),d3
  3740.     blt    .safe
  3741.     cmp.w    bull_lazy2(a2),d3
  3742.     bgt    .safe
  3743.     ;HAHHHAHAHAHHHHAAX KILL KILL BANG BANG YOUR DEAD KILL KILL
  3744.     move.b    #DYING,play_status(a1)    
  3745. ;    move.b    #DEAD,play_status(a1)    
  3746.     move.w    #$fff,flash
  3747.  
  3748.  
  3749. .safe    
  3750. .deadlazer    add.l    #bullet_nd-bullet,a2    ;next bullet
  3751.     dbra    d6,.lazloop
  3752.     
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.     move.l    play_actual(a1),play_was(a1)
  3763.     clr.l    d0
  3764.     clr.l    d1
  3765.     move.w    play_xpos(a1),d0
  3766.     move.w    play_ypos(a1),d1
  3767.     sub.w    #8,d1        ;player is 24 high
  3768.     mulu    #scrwid*5,d1
  3769.  
  3770.     move.w    d0,d2    ;save x
  3771.     and.w    #$000f,d0
  3772.     rol.w    #8,d0
  3773.     rol.w    #4,d0    ;got minterm
  3774.     and.w    #$fff0,d2    ;do corse scrol
  3775.     ror.w    #3,d2
  3776.     add.w    d2,d1    ;got coarse
  3777.     move.l    d1,play_actual(a1)    ;save coarse scroll
  3778.     move.w    d0,play_smooth(a1)    ;save smooth    
  3779.     
  3780.     ;if playwas = 0 then copy actual into it
  3781.     cmp.l    #0,play_was(a1)
  3782.     bne    .okay
  3783.     move.l    play_actual(a1),play_was(a1)
  3784. .okay
  3785.  
  3786.     CALLGRAF    WaitBlit
  3787.     add.l    scrbase,d1    
  3788.     move.w    #scrwid-4,$dff064    ;mod A
  3789.     move.w    #4-4,$dff066    ;mod D
  3790.     move.l    d1,$dff050    ;src A
  3791.     move.l    a4,$dff054    ;dst D
  3792.     move.w    #$09f0,$dff040    ;bltcon0!!!!!
  3793.     move.w    #(24*5*64)+2,$dff058    ;bltsize 
  3794.  
  3795. .dead    
  3796.     add.l    #24*4*5,a4    ;next grab place please
  3797.     add.l    #player1_nd-player1,a1    ;next player
  3798.     dbra    d7,.loop
  3799.  
  3800.  
  3801.     rts
  3802. go_printplayer1
  3803.     clr.l    d7
  3804.     move.b    num_players,d7
  3805.     sub.l    #1,d7    ;for dbra
  3806.  
  3807.     lea    player1,a1
  3808. .loop
  3809.     ;is player dead. if so skip it
  3810.     cmp.b    #DEAD,play_status(a1)    
  3811.     beq    .dead
  3812.     ;or dying
  3813.     cmp.b    #DYING,play_status(a1)    
  3814.     beq    .dead
  3815.  
  3816.     ;A = mask
  3817.     ;B = source
  3818.     ;C = dest
  3819.     ;D = dest. (obvious really!!)
  3820.     
  3821.     CALLGRAF    WaitBlit
  3822.     move.w    #$ffff,$dff044    ;fwm
  3823.     move.w    #$ffff,$dff046    ;lwm
  3824.     move.w    #40-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  3825.     move.w    #40-4,$dff062    ;mod b
  3826.     move.w    #scrwid-4,$dff060    ;mod C
  3827.     move.w    #scrwid-4,$dff066    ;mod D
  3828.  
  3829.     move.w    play_smooth(a1),d0    ;get smooth
  3830.     move.w    d0,$dff042    
  3831.     or.w    #$0fce,d0
  3832.     move.w    d0,$dff040    
  3833.     
  3834.     move.l    scrbase,a4        ;get coarse
  3835.     add.l    play_actual(a1),a4
  3836.     
  3837.     move.l    Player1Base,a5
  3838.  
  3839.     ;point to the mask
  3840.     move.l    a5,a3
  3841.     add.l    #40*48*5,a3        ;gott it
  3842.  
  3843.     ;if player has been hurt make him white.. cheat and use mask!
  3844.     cmp.b    #HURT,play_status(a1)
  3845.     bne    .nohurt
  3846.     move.l    a3,a5
  3847.     sub.b    #1,play_hptime(a1)
  3848.     cmp.b    #0,play_hptime(a1)
  3849.     bne    .nohurt
  3850.     move.b    #OKAY,play_status(a1)
  3851.     
  3852. .nohurt
  3853.  
  3854.     clr.l    d0
  3855.     clr.l    d1
  3856.     move.b    play_anim_style(a1),d0    ;get style
  3857. ;    move.b    #0,d0    ;frigging
  3858.     mulu    #40*24*5,d0        ;get to anim set
  3859.     
  3860.     move.b    play_anim_frame(a1),d1    ;get frame
  3861. ;    move.b    #7,d1    ;frigging
  3862.     lsl.l    #2,d1
  3863.     add.l    d1,d0
  3864.     add.l    d0,a5    ;add to player gfx
  3865.     add.l    d0,a3    ;add to player mask
  3866.     
  3867.     move.l    a3,$dff050    ;get mask A
  3868.     move.l    a5,$dff04c    ;src B    bob
  3869.     move.l    a4,$dff048    ;src C    screen
  3870.     move.l    a4,$dff054    ;dst D    screen
  3871.     move.w    #(24*5*64)+2,$dff058
  3872.  
  3873. .dead
  3874.     add.l    #player1_nd-player1,a1    ;next player
  3875.     dbra    d7,.loop
  3876.  
  3877.     rts
  3878.  
  3879. go_findplayers        
  3880.     move.b    #0,num_players
  3881.     ;8 = players
  3882.     move.l    LevBase,a0    ;point to start of level
  3883.     lea    player1,a1
  3884.     move.b    #players_max,temp
  3885.         
  3886.     move.l    #16,d1    ;clear y
  3887.     move.w    #level_hi-1,d6
  3888. .loop3
  3889.     move.l    #16,d0    ;clear x
  3890.     move.w    #level_wid-1,d7
  3891.     move.l    a0,a2    ;pointer to level
  3892. .loop2
  3893.     move.l    (a2)+,d2
  3894.     and.l    #$ffff0000,d2    ;kill gfk
  3895.     swap    d2        ;get the char
  3896.     cmp.l    #8,d2
  3897.     bne    .not_player
  3898.     
  3899.     bsr    create_player
  3900.     
  3901.     add.l    #player1_nd-player1,a1    ;next player please
  3902.     add.b    #1,num_players    ;add to player count
  3903.     sub.b    #1,temp
  3904.     cmp.b    #0,temp
  3905.     beq    .out
  3906. .not_player
  3907.     add.l    #16,d0        ;next xpos
  3908.     dbra    d7,.loop2
  3909.     add.l    #level_wid*4,a0
  3910.     add.l    #16,d1
  3911.     dbra    d6,.loop3
  3912.     
  3913.     
  3914.  
  3915. .out    rts
  3916.  
  3917. create_player
  3918.     move.w    d0,play_xpos(a1)    ;save x
  3919.     move.w    d1,play_ypos(a1)    ;save y
  3920. ;    sub.w    #8,play_ypos(a1)    ;player is 24 high
  3921.  
  3922.     ;now work out map pos
  3923.     move.w    d0,d2        ;
  3924.     and.l    #$0000fff0,d2    ;kill all orrible bits
  3925.     ror.w    #4,d2        ;shift down
  3926.     move.b    d2,play_mapx(a1)    ;save player mapx
  3927.  
  3928.     move.w    d1,d2        ;
  3929.     and.l    #$0000fff0,d2    ;kill all orrible bits
  3930.     ror.w    #4,d2        ;shift down
  3931.     move.b    d2,play_mapy(a1)    ;save player mapy
  3932.  
  3933.     clr.l    d2    ;x
  3934.     clr.l    d3    ;y
  3935.     move.w    play_xpos(a1),d2    ;get player xpos
  3936.     move.w    play_ypos(a1),d3    ;get player ypos
  3937.     sub.w    #8,d3    ;player is 24 high
  3938.     
  3939.     mulu    #scrwid*5,d3    ;got y
  3940.     and.w    #$fff0,d2    ;do corse scrol
  3941.     ror.w    #3,d2
  3942.     add.w    d2,d3    ;got coarse
  3943.     
  3944.     move.l    d3,play_was(a1)    ;save actual (just add scrbase)
  3945.     
  3946.     move.b    #16,play_platx(a1)
  3947.     move.b    #1,play_speed(a1)    ;start speed
  3948.     move.b    #60,play_spdmax(a1)    ;max speed
  3949.     move.b    #4,play_step(a1)    ;step through table
  3950.     move.b    #8,play_slip(a1)    ;how slippy surface
  3951.     move.b    #gravity,play_falmax(a1)    ;max fall speed!
  3952.     move.b    #OKAY,play_status(a1)    ;hey im alive!
  3953.  
  3954.     move.b    #HitPoints,play_hp(a1)    ;player hit points
  3955.     
  3956.     move.b    #WeapBounce,play_gun(a1)    ;players gun
  3957. ;    move.b    #WeapNorm,play_gun(a1)    ;players gun
  3958.     move.b    #255,play_ammo(a1)        ;ammo (infinite)
  3959.     move.b    #10,play_reloadmax(a1)        ;take 100 vbl to reload
  3960.     ;good num... 30 or 10 for ace
  3961.     move.b    #gun_max/players_max,play_maxbulls(a1)        ;max bullets on screen!!!!
  3962.     move.b    #0,play_maxbullscnt(a1)        ;zero bullet count
  3963.     move.b    #1,play_gunpower(a1)
  3964.     
  3965.     ;figure out what port hes reading from....
  3966.     lea    OPTP1JOY,a3        ;point to joystick options.
  3967.     ;num players has player num
  3968.     clr.l    d2
  3969.     move.b    num_players,d2
  3970.     move.b    (a3,d2),play_port(a1)    ;copy port
  3971.     rts
  3972.  
  3973. joyport1
  3974.     clr.l    d1
  3975.     move.w    $dff00c,d0    ;$dff00a port one
  3976.     btst    #9,d0
  3977.     beq    .not_left
  3978.     bset    #1,d1        ;left
  3979. .not_left
  3980.     btst    #1,d0
  3981.     beq    .not_right        
  3982.     bset    #0,d1        ;right
  3983. .not_right
  3984.     move.w    d0,d2
  3985.     lsr.w    #1,d2
  3986.     eor.w    d0,d2
  3987.     btst    #0,d2
  3988.     beq    .not_down
  3989.     bset    #2,d1        ;down
  3990. .not_down    btst    #8,d2
  3991.     beq    .not_up
  3992.     bset    #3,d1        ;up
  3993. .not_up    
  3994.     move.l    d1,d0        ;save in d0
  3995.  
  3996.     ;now check for fire button
  3997.     btst    #7,$bfe001        ;PRA (6 for the other port)
  3998.     bne    .loop
  3999. ;    move.w    #$0f00,$dff180
  4000.     bset    #BOBB_SHOOT,d0    ;hey i hit the button
  4001.     
  4002. .loop    rts
  4003.  
  4004. joyport2
  4005.     clr.l    d1
  4006.     move.w    $dff00a,d0        ;dff00c port1
  4007.     btst    #9,d0
  4008.     beq    .not_left
  4009.     bset    #1,d1        ;left
  4010. .not_left
  4011.     btst    #1,d0
  4012.     beq    .not_right        
  4013.     bset    #0,d1        ;right
  4014. .not_right
  4015.     move.w    d0,d2
  4016.     lsr.w    #1,d2
  4017.     eor.w    d0,d2
  4018.     btst    #0,d2
  4019.     beq    .not_down
  4020.     bset    #2,d1        ;down
  4021. .not_down    btst    #8,d2
  4022.     beq    .not_up
  4023.     bset    #3,d1        ;up
  4024. .not_up    
  4025.     move.l    d1,d0        ;save in d0
  4026.  
  4027.     ;now check for fire button
  4028.     btst    #6,$bfe001        ;PRA (7 for the other port)
  4029.     bne    .loop
  4030. ;    move.w    #$0f00,$dff180
  4031.     bset    #BOBB_SHOOT,d0    ;hey i hit the button
  4032.     
  4033. .loop    rts
  4034.  
  4035. go_moveplayer1
  4036.     lea    player1,a1
  4037.     clr.l    d7
  4038.     move.b    num_players,d7
  4039.     sub.l    #1,d7    ;for dbra
  4040.  
  4041. .loop
  4042.     cmp.b    #DEAD,play_status(a1)
  4043.     beq    .hesdead
  4044.     ;choose which port to read from (not written)
  4045.     cmp.b    #JOYPORT1,play_port(a1)
  4046.     bne    .notport1
  4047.     bsr    joyport1
  4048. .notport1    cmp.b    #JOYPORT2,play_port(a1)
  4049.     bne    .notport2
  4050.     bsr    joyport2
  4051. .notport2
  4052.     move.b    d0,play_do(a1)
  4053.     
  4054.     move.l    d7,RegSave
  4055.     bsr    play_move
  4056.     move.l    RegSave,d7
  4057.  
  4058. .hesdead    add.l    #player1_nd-player1,a1    ;next player please
  4059.     dbra    d7,.loop
  4060.     rts
  4061.     
  4062. play_move
  4063.     bsr    player_right
  4064.     bsr    player_left
  4065.     bsr    player_up
  4066.     bsr    player_down
  4067.     bsr    player_fire
  4068.  
  4069.  
  4070. ;---------------
  4071. ;proper LR inertia for player (slippy slidey like mario)    
  4072. ;if the joystick hasnt been pushed LR or the flags
  4073. ;lowered by the lr routines then do inertia on player
  4074. ;---------------
  4075.     
  4076.     ;if no LR (play_do) then slow down the player
  4077.     
  4078.     clr.l    d0
  4079.     move.b    play_do(a1),d0    ;get joystick dir
  4080.     and.b    #BOBF_RIGHT|BOBF_LEFT,d0
  4081.     bne    .no_lr
  4082.     ;player is going left or right!!!!!!
  4083.     
  4084.     ;if players speed at 0 then just exit
  4085.     cmp.b    #0,play_speed(a1)
  4086.     beq    .no_lr
  4087.     
  4088.     clr.l    d0
  4089.     
  4090.     move.b    play_slip(a1),d0
  4091.     ;if player is falling then play_slip = 1
  4092.     btst    #BOBB_FALL,play_doing(a1)
  4093.     beq    .onland
  4094.     move.b    #1,d0
  4095. .onland
  4096.     
  4097.     sub.b    d0,play_speed(a1)
  4098.     bgt    .ok
  4099.     move.b    #0,play_speed(a1)
  4100. .ok
  4101.     bsr    player_right_BYPASS
  4102.     bsr    player_left_BYPASS
  4103.     bra    .out
  4104. .no_lr
  4105.     ;okay, guy is stationary (I think)
  4106.     ;Now we can do other things.
  4107.     ;if play_platx(a1) under 8 or over 24
  4108.     ;and guy is on edge do balance thing (Sonic)
  4109. .out
  4110.     rts
  4111. player_right
  4112.     btst    #BOBB_RIGHT,play_do(a1)    
  4113.     beq    .not_right
  4114.  
  4115.     ;if play_going = left then just slow speed down to 0
  4116.     ;and then clear left and set right
  4117.     btst    #BOBB_LEFT,play_going(a1)
  4118.     beq    .okr
  4119.     cmp.b    #0,play_speed(a1)
  4120.     bgt    .slowmedown
  4121.     bclr    #BOBB_LEFT,play_going(a1)
  4122.     bset    #BOBB_RIGHT,play_going(a1)
  4123.     bra    .not_right
  4124. .slowmedown
  4125.     sub.b    #1,play_speed(a1)
  4126.     bclr    #BOBB_RIGHT,play_do(a1)    
  4127.     bra    .not_right
  4128. .okr
  4129.  
  4130.     clr.l    d0
  4131.     move.b    play_speed(a1),d0
  4132.     cmp.b    play_spdmax(a1),d0
  4133.     bge    .atmax
  4134.     
  4135.     move.b    play_step(a1),d1
  4136.     add.b    d1,play_speed(a1)
  4137. .atmax
  4138.     bset    #BOBB_RIGHT,play_going(a1)
  4139.     bsr    player_right_BYPASS
  4140.  
  4141.     move.b    #Anim_RIGHT,play_anim_style(a1)
  4142.     cmp.b    #7,play_anim_frame(a1)
  4143.     blt    .noreset
  4144.     move.b    #0,play_anim_frame(a1)
  4145.     move.b    #0,play_anim_count(a1)
  4146. .noreset
  4147.     add.b    #1,play_anim_count(a1)
  4148.     cmp.b    #pamax,play_anim_count(a1)
  4149.     bne    .not_right
  4150.     move.b    #0,play_anim_count(a1)
  4151.     add.b    #1,play_anim_frame(a1)
  4152.  
  4153. .not_right
  4154.     rts
  4155.     
  4156. player_right_BYPASS
  4157.     clr.l    d0
  4158.     move.b    play_speed(a1),d0
  4159.     lea    play_walk,a0
  4160.     move.b    (a0,d0),d0
  4161.  
  4162.     btst    #BOBB_RIGHT,play_going(a1)
  4163.     beq    .not_right
  4164.     
  4165.     add.w    d0,play_xpos(a1)
  4166.     cmp.w    #21*16,play_xpos(a1)
  4167.     blt    .onscreen
  4168.     ;going off the right hand side. sub loads to get him across
  4169.     sub.w    #21*16,play_xpos(a1)
  4170.     sub.b    #21,play_mapx(a1)        
  4171. .onscreen
  4172.     add.b    d0,play_platx(a1)
  4173.     cmp.b    #32,play_platx(a1)
  4174.     blt    .not_overr
  4175.     ;completely in new square, so do summink!
  4176.     sub.b    #16,play_platx(a1)
  4177.     add.b    #1,play_mapx(a1)
  4178.     
  4179.     clr.l    d0
  4180.     clr.l    d1
  4181.     move.b    play_mapx(a1),d0
  4182.     move.b    play_mapy(a1),d1
  4183.     add.b    #1,d1    ;check under foot
  4184.     bsr    find_char
  4185.  
  4186.     lea    walk_on,a2        ;what chars can you walk on
  4187. .walkingon
  4188.     cmp.b    #0,(a2)
  4189.     beq    .not_pform        ;not on pform
  4190.     cmp.b    (a2)+,d0
  4191.     beq    .not_overr        ;all groovy (on PFORM)
  4192.     bra    .walkingon
  4193. .not_pform
  4194.     ;set fall bit
  4195.     btst    #BOBB_FALL,play_doing(a1)    ;am i already falling
  4196.     bne    .not_right    ;yep
  4197.     move.b    #0,play_fal(a1)        ;reset fall count
  4198.     bset    #BOBB_FALL,play_doing(a1)    ;hey fall
  4199.     bset    #BOBB_DOWN,play_do(a1)        ;hey down
  4200.     bra    .not_right
  4201.  
  4202. .not_overr
  4203. .not_right
  4204.     rts
  4205. player_left    
  4206.     btst    #BOBB_LEFT,play_do(a1)    
  4207.     beq    .not_left
  4208.     
  4209.     ;if play_going = right then just slow speed down to 0
  4210.     ;and then clear right and set left
  4211.     btst    #BOBB_RIGHT,play_going(a1)
  4212.     beq    .okl
  4213.     cmp.b    #0,play_speed(a1)
  4214.     bgt    .slowmedown
  4215.     bclr    #BOBB_RIGHT,play_going(a1)
  4216.     bset    #BOBB_LEFT,play_going(a1)
  4217.     bra    .not_left
  4218. .slowmedown
  4219.     sub.b    #1,play_speed(a1)
  4220.     bclr    #BOBB_LEFT,play_do(a1)    
  4221.     bra    .not_left
  4222. .okl
  4223.  
  4224.     clr.l    d0
  4225.     move.b    play_speed(a1),d0
  4226.     cmp.b    play_spdmax(a1),d0
  4227.     bge    .atmax
  4228.     
  4229.     move.b    play_step(a1),d1
  4230.     add.b    d1,play_speed(a1)
  4231.     
  4232. .atmax
  4233.     bset    #BOBB_LEFT,play_going(a1)
  4234.     bsr    player_left_BYPASS
  4235.  
  4236.     move.b    #Anim_LEFT,play_anim_style(a1)
  4237.     cmp.b    #7,play_anim_frame(a1)
  4238.     blt    .noreset1
  4239.     move.b    #0,play_anim_frame(a1)
  4240.     move.b    #0,play_anim_count(a1)
  4241. .noreset1
  4242.     add.b    #1,play_anim_count(a1)
  4243.     cmp.b    #pamax,play_anim_count(a1)
  4244.     bne    .not_left
  4245.     move.b    #0,play_anim_count(a1)
  4246.  
  4247.     add.b    #1,play_anim_frame(a1)
  4248.  
  4249. .not_left
  4250.     rts    
  4251.     
  4252. player_left_BYPASS
  4253.     clr.l    d0
  4254.     move.b    play_speed(a1),d0
  4255.     lea    play_walk,a0
  4256.     move.b    (a0,d0),d0
  4257.  
  4258.     btst    #BOBB_LEFT,play_going(a1)
  4259.     beq    .not_left
  4260.     
  4261.     sub.w    d0,play_xpos(a1)
  4262.     cmp.w    #0,play_xpos(a1)
  4263.     bgt    .onscreen
  4264.     ;going off the left hand side. add loads to get him across
  4265.     add.w    #21*16,play_xpos(a1)
  4266.     add.b    #21,play_mapx(a1)        
  4267. .onscreen
  4268.     sub.b    d0,play_platx(a1)
  4269.     cmp.b    #0,play_platx(a1)
  4270.     bgt    .not_underl
  4271.     ;completely in new square, so do summink!
  4272.     add.b    #16,play_platx(a1)
  4273.     sub.b    #1,play_mapx(a1)
  4274.  
  4275.     clr.l    d0
  4276.     clr.l    d1
  4277.     move.b    play_mapx(a1),d0
  4278.     move.b    play_mapy(a1),d1
  4279.     add.b    #1,d1    ;check under foot
  4280.     bsr    find_char
  4281.  
  4282.     lea    walk_on,a2        ;what chars can you walk on
  4283. .walkingon
  4284.     cmp.b    #0,(a2)
  4285.     beq    .not_pform        ;not on pform
  4286.     cmp.b    (a2)+,d0
  4287.     beq    .not_underl        ;all groovy (on PFORM)
  4288.     bra    .walkingon
  4289. .not_pform
  4290.  
  4291.     ;set fall bit
  4292.     btst    #BOBB_FALL,play_doing(a1)    ;am i already falling
  4293.     bne    .not_left    ;yep
  4294.     move.b    #0,play_fal(a1)        ;reset fall count
  4295.     bset    #BOBB_FALL,play_doing(a1)    ;hey fall
  4296.     bset    #BOBB_DOWN,play_do(a1)        ;hey down
  4297.     bra    .not_left
  4298.  
  4299. .not_underl
  4300. .not_left
  4301.     rts
  4302.  
  4303. player_down
  4304.     ;note if player is just pulling down then make him duck! * not written *
  4305.  
  4306.     btst    #BOBB_JUMP,play_doing(a1)    
  4307.     bne    .not_down
  4308.  
  4309.     btst    #BOBB_DOWN,play_do(a1)    
  4310.     bne    .down_override
  4311.  
  4312.     btst    #BOBB_FALL,play_doing(a1)    
  4313.     beq    .not_down
  4314. .down_override
  4315.     cmp.w    #(scrhi*16)-(24+8),play_ypos(a1)    ;********16
  4316.     blt    .not_bottom
  4317.     
  4318. ;    bra    .not_down
  4319.     ;reached bottom of the screen.. FUCK
  4320.     move.w    #8+16,play_ypos(a1)
  4321.     move.b    #1,play_mapy(a1)
  4322. .not_bottom
  4323.  
  4324.     lea    bad_walk,a2
  4325.     clr.l    d0
  4326.     
  4327.     add.b    #1,play_fal(a1)    ;next table pos
  4328.     move.b    play_fal(a1),d0
  4329.     cmp.b    play_falmax(a1),d0    ;at max speed?
  4330.     blt    .freefal
  4331.     ;reached max
  4332.     sub.b    #1,play_fal(a1)
  4333.     sub.b    #1,d0
  4334. .freefal
  4335.     move.b    (a2,d0),d0        ;get speed
  4336.  
  4337.     move.w    play_ypos(a1),d1    ;save for check
  4338.     and.l    #$fff0,d1        ;kill of tiny ones    
  4339.     
  4340.     add.w    d0,play_ypos(a1)    ;move down please
  4341.     
  4342.     clr.l    d0
  4343.     move.w    play_ypos(a1),d0    ;get for mapy check
  4344.     and.l    #$fff0,d0        ;kill of tiny ones    
  4345.     
  4346.     cmp.w    d0,d1
  4347.     beq    .okay        ;still on same block
  4348.     
  4349.     add.b    #1,play_mapy(a1)    ;down a block please
  4350.  
  4351.     cmp.b    #1,play_cres(a1)    ;hey im in the cresent part of the jump
  4352.     bne    .okay
  4353.     move.b    #0,play_cres(a1)    ;clear it for later
  4354.     bra    .still_falling
  4355.  
  4356. .okay    
  4357.     ;now check to see if we hit anything
  4358.  
  4359.     cmp.b    #1,play_cres(a1)    ;hey im in the cresent part of the jump
  4360.     beq    .still_falling
  4361.  
  4362.  
  4363.  
  4364.     clr.l    d0
  4365.     clr.l    d1
  4366.     move.b    play_mapx(a1),d0
  4367.     move.b    play_mapy(a1),d1
  4368.  
  4369.     add.b    #1,d1    ;check under foot
  4370.  
  4371.     bsr    find_char
  4372.  
  4373.     lea    walk_on,a2        ;what chars can you walk on
  4374. .underneath
  4375.     cmp.b    #0,(a2)
  4376.     beq    .still_falling
  4377.     cmp.b    (a2)+,d0
  4378.     beq    .found_platform
  4379.     bra    .underneath
  4380. .found_platform
  4381.     move.w    play_ypos(a1),d0
  4382.     and.w    #$fff0,d0
  4383.     move.w    d0,play_ypos(a1)    ;make on top of pform
  4384. ;    add.w    #8,play_ypos(a1)    ;hes 24 high (allowed for)
  4385.     ;hey stop falling dude
  4386.     bclr    #BOBB_DOWN,play_do(a1)    
  4387.     bclr    #BOBB_FALL,play_doing(a1)    
  4388. .still_falling
  4389. .not_down
  4390.     rts
  4391. player_up
  4392.     ;am i jumping?
  4393.     btst    #BOBB_JUMP,play_doing(a1)
  4394.     bne    .jump
  4395.  
  4396.     
  4397.     btst    #BOBB_UP,play_do(a1)    
  4398.     beq    .not_up
  4399.  
  4400.     ;if player is falling then he CANNOT perform a jump!
  4401.     btst    #BOBB_FALL,play_doing(a1)    ;am i already falling
  4402.     bne    .not_up            
  4403.     
  4404.     ;okay player is not falling so we can set the jump bit and set it all up
  4405.     btst    #BOBB_JUMP,play_doing(a1)    ;am i already jumping
  4406.     bne    .not_up            
  4407.     
  4408.     bset    #BOBB_JUMP,play_doing(a1)
  4409.     bset    #BOBB_UP,play_do(a1)    
  4410.     move.b    #24,play_jmp_pos(a1)        ;reset jump cnt
  4411.     
  4412.     bra    .not_up    
  4413.  
  4414. .jump    
  4415.     move.w    play_ypos(a1),d1
  4416.     and.l    #$0000fff0,d1    ;kill off old xpos fine
  4417.  
  4418.     clr.l    d0
  4419.     ;if in jump mode then get speed!
  4420.     btst    #BOBB_JUMP,play_doing(a1)
  4421.     beq    .skipd0        ;not jumping
  4422.     cmp.b    #0,play_jmp_pos(a1)
  4423.     bne    .no_climax
  4424.     ;reached top of jump. now switch off jump and gravity do the rest!
  4425.     bclr    #BOBB_JUMP,play_doing(a1)    ;stop jumpping ya bastard
  4426.     bset    #BOBB_FALL,play_doing(a1)    ;fall ya bastard
  4427.     bset    #BOBB_DOWN,play_do(a1)    ;set going down bit please 
  4428.     move.b    #0,play_fal(a1)
  4429.     move.b    #1,play_cres(a1)    ;hey im in the cresent part of the jump
  4430.     bra    .not_up
  4431. .no_climax
  4432.     sub.b    #1,play_jmp_pos(a1)
  4433.     move.b    play_jmp_pos(a1),d0    ;get the counter
  4434.     lea    bad_jump,a2        ;use the same jump table as bad
  4435.     move.b    (a2,d0),d0        ;got the speed!
  4436.     bra    .skipd0
  4437.     
  4438.     move.b    play_speed(a1),d0
  4439. .skipd0
  4440.     sub.w    d0,play_ypos(a1)    ;move up please
  4441.  
  4442.     move.w    play_ypos(a1),d0    ;
  4443.     and.l    #$0000fff0,d0    ;kill off new xpos fine
  4444.     cmp.b    d0,d1
  4445.     beq    .same4        ;hasnt crossed boundary!
  4446.     sub.b    #1,play_mapy(a1)
  4447. ;    ;check above player just for walk_thru chars
  4448.  
  4449. .same4
  4450.     cmp.w    #0,play_ypos(a1)    ;edge of screen?
  4451.     bgt    .okay4
  4452.     ;at edge, please turn around
  4453.     move.w    #0,play_ypos(a1)
  4454.     move.b    #0,play_mapy(a1)
  4455.     bclr    #BOBB_UP,play_do(a1)    ;clear up
  4456.     bset    #BOBB_DOWN,play_do(a1)    ;set down
  4457. .okay4
  4458.     bra    .not_up
  4459. .not_up
  4460.     rts
  4461.     
  4462. player_fire
  4463.     btst    #BOBB_SHOOT,play_do(a1)
  4464.     beq    .out        ;finger off button
  4465.     
  4466.     ;ah, hes hit the fire button.... FUCK!
  4467.     ;is he waiting for a reload?
  4468.     cmp.b    #0,play_reloadcnt(a1)
  4469.     beq    .reloaded
  4470.     ;still reloading!
  4471.     sub.b    #1,play_reloadcnt(a1)
  4472.     bra    .nofire
  4473.     
  4474. .reloaded
  4475.     ;ok, has he got any ammo? (255 = infinite)
  4476.     cmp.b    #0,play_ammo(a1)
  4477.     beq    .nofire        ;no ammon
  4478.     cmp.b    #255,play_ammo(a1)
  4479.     beq    .infinite
  4480.     sub.b    #1,play_ammo(a1)    
  4481. .infinite
  4482.     ;are all his bullets on the screen?
  4483.     clr.l    d0
  4484.     move.b    play_maxbulls(a1),d0
  4485.     cmp.b    play_maxbullscnt(a1),d0
  4486.     beq    .nofire
  4487.     
  4488.     ;ok, we can shoot!
  4489.     add.b    #1,play_maxbullscnt(a1)
  4490.     move.b    play_reloadmax(a1),d0
  4491.     move.b    d0,play_reloadcnt(a1)
  4492.  
  4493. ;    move.w    #$ff0,$dff180
  4494.  
  4495.     bsr    find_sparebull    ;find im and set him up!!!!
  4496.  
  4497.     cmp.b    #DEAD,bull_status(a2)
  4498.     beq    .dead    
  4499. .nofire
  4500.     rts
  4501. .out
  4502.     move.b    #0,play_reloadcnt(a1)
  4503.     rts
  4504. .dead
  4505.     sub.b    #1,play_maxbullscnt(a1)
  4506.     rts
  4507.     
  4508. find_sparebull
  4509.     clr.l    d7
  4510.     ;lets see if weve got any spare bullet bobs!
  4511.     lea    gun_list,a2
  4512.     move.l    #gun_max-1,d7
  4513. .loop
  4514.     ;find a dead bullet (status = DEAD)
  4515.     cmp.b    #DEAD,bull_status(a2)
  4516.     bne    .not_dead
  4517.     ;okay, weve found a bullet. Now lets get it up and running
  4518.  
  4519.     ;clear structure for new bullet
  4520.     move.l    a2,a3
  4521.     move.l    #bullet_nd-bullet-1,d6    
  4522. .blank    move.b    #0,(a3)+
  4523.     dbra    d6,.blank
  4524.  
  4525.     bset    #BOBB_GUN2,play_doing(a1)
  4526.     move.b    play_gun(a1),bull_gun(a2)    ;copy weapon type
  4527.  
  4528.     move.l    a1,bull_paddr(a2)
  4529.     
  4530.     move.w    play_xpos(a1),d0
  4531.     move.w    d0,bull_xpos(a2)
  4532.     move.w    play_ypos(a1),d0
  4533.     move.w    d0,bull_ypos(a2)
  4534.     bset    #BOBB_LEFT,bull_go(a2)
  4535.     bset    #BOBB_LEFT,bull_wantgo(a2)
  4536.     move.b    play_gunpower(a1),bull_power(a2)
  4537.  
  4538.     bsr    initplaybull
  4539.  
  4540.     bsr    bullet_setup
  4541.  
  4542.  
  4543.  
  4544.     bra    .out
  4545. .not_dead
  4546.     add.l    #bullet_nd-bullet,a2    ;next bullet
  4547.     dbra    d7,.loop
  4548. .out    rts
  4549.  
  4550. initplaybull
  4551.  
  4552.     move.w    play_gungfk(a1),bull_gfk(a2)
  4553.  
  4554.     move.w    #88+24,bull_gfk(a2)    ;**************** REMOVE ME ************
  4555.  
  4556.     bsr    prepbull2    ;this set all up but wantgo & go    
  4557.  
  4558.     move.w    play_ypos(a1),bull_ypos(a2)
  4559.     
  4560.     move.b    #0,bull_go(a2)
  4561.     move.b    #0,bull_wantgo(a2)
  4562.     
  4563.     clr.l    d0
  4564.     move.w    play_xpos(a1),d0
  4565.     ;if facing left and xpos over 16 then
  4566.  
  4567.     ;the weapnorm baddy may not be moving l/r 
  4568.     ;so look at cango to decide which way to shoot!
  4569.  
  4570.     btst    #BOBB_LEFT,play_going(a1)    ;check player
  4571.     beq    .not_left
  4572.  
  4573. .normjumpl    ;okay, hes facing left. Is his xpos over 16?
  4574.     cmp.w    #16,play_xpos(a1)
  4575.     bgt    .okayl
  4576.     ;on very edge of screen, so kill me off
  4577.     move.b    #DEAD,bull_status(a2)    ;kill bullet off again
  4578. .okayl
  4579.     ;okay its safe to do so
  4580.     sub.w    #16,d0
  4581.     move.w    d0,bull_xpos(a2)
  4582.     move.b    #0,bull_go(a2)
  4583.     move.b    #0,bull_wantgo(a2)
  4584.     bset    #BOBB_LEFT,bull_go(a2)
  4585.     bset    #BOBB_LEFT,bull_wantgo(a2)
  4586. .not_left
  4587.  
  4588.  
  4589.  
  4590.     ;if baddy facing right and xpos under 320+16-16 then
  4591.     btst    #BOBB_RIGHT,play_going(a1)    ;check player
  4592.     beq    .not_right
  4593. .normjumpr    ;okay, hes facing right. Is his xpos over 320+16-16?
  4594.     cmp.w    #320+16-16,play_xpos(a1)    ;edge of screen?
  4595.     blt    .okayr
  4596.     ;on very edge of screen, so kill me off
  4597.     move.b    #DEAD,bull_status(a2)    ;kill bullet off again
  4598. .okayr
  4599.     ;okay its safe to do so
  4600.     add.w    #16,d0
  4601.     move.w    d0,bull_xpos(a2)
  4602.     move.b    #0,bull_go(a2)
  4603.     move.b    #0,bull_wantgo(a2)
  4604.     bset    #BOBB_RIGHT,bull_go(a2)
  4605.     bset    #BOBB_RIGHT,bull_wantgo(a2)
  4606. .not_right
  4607.     
  4608. .out    rts
  4609.  
  4610. go_collision
  4611.  
  4612.     bsr    player_to_baddyNbullet
  4613.  
  4614.     bsr    bullet_to_baddy
  4615.     
  4616.     rts
  4617.  
  4618. bullet_to_baddy
  4619.     lea    bad_no,a4        ;pointer to baddy list
  4620. .main
  4621.     bsr    findbadptr
  4622.     cmp.l    #0,d0
  4623.     beq    .out        ;done all baddies
  4624.  
  4625.  
  4626. ;    PUSHALL
  4627. ;    bsr    blitcollbaddy
  4628. ;    PULLALL
  4629.  
  4630.     lea    gun_list,a1        ;pointer to players gun list
  4631.     clr.l    d5        ;gun counter!
  4632. .checking
  4633.  
  4634.     ;check to see if bullet is alive
  4635.     cmp.b    #OKAY,bull_status(a1)
  4636.     bne    .nobulls
  4637.  
  4638. .okay
  4639.     bsr    guntobadxy
  4640.     cmp.l    #0,d0
  4641.     beq    .nobulls        ;nowhere near. no blit coll
  4642.     
  4643. ;    move.w    #$f00,$dff180    
  4644.     ;hey, were near a baddy!
  4645.     ;do blit check......
  4646.  
  4647. ;    bsr    bulltobadblit    ;blit bullet on to collision
  4648. ;    cmp.l    #0,d0
  4649. ;    beq    .nobulls         ;no collision!
  4650. ;    ;hey weve hit!!!!
  4651. ;    move.w    #$0f0,$dff180
  4652.  
  4653.     ;first do something funny to the bullet!
  4654.     clr.l    d0
  4655.     move.b    bull_go(a1),d0
  4656.     or.b    #BOBF_DOWN,d0
  4657.     move.b    d0,bull_go(a1)
  4658.  
  4659.     clr.l    d0
  4660.     move.b    bull_power(a1),d0
  4661.     bsr    hurtbaddy
  4662.     move.b    #0,bull_power(a1)
  4663.  
  4664. .nobulls
  4665.     add.l    #bullet_nd-bullet,a1    ;next bullet
  4666.     add.b    #1,d5
  4667.     cmp.b    #gun_max-1,d5
  4668.     ble    .checking
  4669.  
  4670. ;    PUSHALL
  4671. ;    bsr    clearcollbaddy
  4672. ;    PULLALL
  4673.     bra    .main        ;loop forever
  4674.     
  4675. .out    rts
  4676.  
  4677. player_to_baddyNbullet
  4678.     clr.l    d7        ;player counter!
  4679.     clr.l    d6        ;baddy/bullet counter!
  4680.     clr.l    d5        ;bullet count
  4681.     lea    bad_no,a4        ;point to baddy list
  4682.     lea    bullet_list,a1    ;point to bullet list
  4683. .main
  4684.     
  4685.     ;---> ALL ROUTINES LEAVE A1/A4 D5/D6/D7 ALONE <---
  4686.     
  4687.     bsr    findplayptr        ;find me an alive player
  4688.     cmp.l    #0,d0
  4689.     beq    .out        ;all players dead!
  4690.  
  4691.     PUSHALL    
  4692.     bsr    blitcollplayer    ;blit player onto collision    
  4693.     PULLALL
  4694.  
  4695. .main2
  4696.     bsr    findbadptr        ;find me an alive baddy    
  4697.     cmp.l    #0,d0
  4698.     beq    .nobads
  4699.     
  4700.     bsr    badtoplayxy        ;are we near each other?
  4701.     cmp.l    #0,d0
  4702.     beq    .nobads        ;nowhere near. no blit coll
  4703.     
  4704.     bsr    badtoplayblit    ;blit baddy on to collision
  4705.     cmp.l    #0,d0
  4706.     beq    .nobads         ;no collision!
  4707.     
  4708.     ;* player has been hit *
  4709. ;    bsr    clearcollplayer    ;clear player from collision    
  4710.  
  4711.     clr.l    d0
  4712.     move.b    bad_power(a5),d0
  4713.  
  4714.     bsr    hurtplayer    
  4715. .nobads
  4716.  
  4717.  
  4718.     ;NOTE US A1 only for bullets!!!!!
  4719.     
  4720.     bsr    findbullptr        ;find me an alive bullet
  4721.     cmp.l    #0,d0
  4722.     beq    .nobulls
  4723.     
  4724.     bsr    bulltoplayxy    ;are we near each other?
  4725.     cmp.l    #0,d0
  4726.     beq    .nobulls        ;nowhere near. no blit coll
  4727.         
  4728.     bsr    bulltoplayblit    ;blit bullet on to collision
  4729.     cmp.l    #0,d0
  4730.     beq    .nobulls         ;no collision!
  4731.     
  4732.     ;* player has been hit *
  4733.     PUSHALL
  4734.     bsr    clearcollplayer    ;clear player from collision    
  4735.     PULLALL
  4736.  
  4737.     ;first do something funny to the bullet!
  4738.     clr.l    d0
  4739.     move.b    bull_go(a1),d0
  4740.     eor.b    #BOBF_UP|BOBF_DOWN|BOBF_LEFT|BOBF_RIGHT,d0
  4741.     move.b    d0,bull_go(a1)
  4742.  
  4743.     clr.l    d0
  4744.     move.b    bull_power(a1),d0
  4745.  
  4746.     bsr    hurtplayer    
  4747. .nobulls
  4748.  
  4749.     ;next baddy pointer !!!!!! AUTOMATIC (in get baddy
  4750.     ;next bullet pointer !!!!!!
  4751.         
  4752.     add.l    #bullet_nd-bullet,a1    ;next bullet
  4753.     add.l    #1,d5        ;next bullet!
  4754.     add.b    #1,d6        ;next baddy/bullet
  4755.     cmp.b    #bnb_max,d6        ;at max of bullets and baddies
  4756.     ble    .main2
  4757.     
  4758.     PUSHALL
  4759.     bsr    clearcollplayer    ;clear player from collision    
  4760.     PULLALL
  4761.         
  4762.     clr.l    d6
  4763.     ;reset baddy pointer
  4764.     lea    bad_no,a4        ;point to baddy list
  4765.     ;reset bullet pointer
  4766.     clr.l    d5        ;bullet count
  4767.     lea    bullet_list,a1    ;point to bullet list
  4768.     
  4769.     ;next player pointer !!!!!!
  4770.     
  4771.     add.b    #1,d7        ;next player
  4772.     cmp.b    #players_max,d7
  4773.     ble    .main
  4774.     
  4775. .out    rts
  4776.  
  4777. hurtplayer    ;how much to hurt player in d0
  4778.  
  4779.     ;okay, player has been hit zap some of his hit points
  4780.     
  4781.     ;make him white for a bit
  4782.     move.b    #HURT,play_status(a6)
  4783.     move.b    #hittime,play_hptime(a6)    ;stay white for this long!
  4784.     
  4785.     sub.b    d0,play_hp(a6)
  4786.     bgt    .nohit
  4787.  
  4788.     ;also remove player from the liveplayers table
  4789.     move.b    #DYING,play_status(a6)    
  4790.  
  4791.     sub.l    #1,d7
  4792.     lea    liveplayers,a0
  4793.     move.b    #$fe,(a0,d7)    ;make player dead!!!!
  4794.  
  4795.     add.l    #1,d7        ;put all back to normal
  4796. .nohit
  4797.     rts
  4798.  
  4799. hurtbaddy    ;how much to hurt baddy in d0
  4800.  
  4801.     ;okay, player has been hit zap some of his hit points
  4802.     
  4803. ;    ;make him white for a bit
  4804. ;    move.b    #HURT,play_status(a5)
  4805. ;    move.b    #hittime,play_hptime(a5)    ;stay white for this long!
  4806.     
  4807.     sub.b    d0,bad_hp(a5)
  4808.     bgt    .nohit
  4809.  
  4810.     ;also remove player from the liveplayers table
  4811.     move.b    #DYING,bad_status(a5)    
  4812. .nohit
  4813.     rts
  4814.  
  4815. findplayptr    
  4816.     ;gimme player number D7 and ill find from there an alive player
  4817.     ;fail if i return 0 in d0
  4818.     ;else addr of player structure in A6
  4819.     ;also checks status to see of hes OKAY
  4820.     
  4821.     ;find me an alive player
  4822.  
  4823. .main
  4824.     ;if d7 over players max then bra .out
  4825.     cmp.b    #players_max,d7
  4826.     bge    .out
  4827.     
  4828.     lea    player1,a6
  4829.     clr.l    d0
  4830.     move.b    d7,d0
  4831. .loop
  4832.     cmp.b    #0,d0
  4833.     beq    .gotim
  4834.     sub.b    #1,d0
  4835.     add.l    #player1_nd-player1,a6    ;next player
  4836.     bra    .loop
  4837. .gotim
  4838.     cmp.b    #OKAY,play_status(a6)
  4839.     beq    .got1
  4840.     add.b    #1,d7    ;next player
  4841.     cmp.b    #players_max,d7
  4842.     beq    .out
  4843.     bra    .loop
  4844. .nodead    
  4845.      ;ALL Routines LEAVE -=> D7 <=- ALONE
  4846.  
  4847.  
  4848. .got1    move.l    #1,d0
  4849.     rts
  4850.  
  4851. .out    ;all players dead!!!!
  4852.     move.l    #0,d0
  4853.     rts
  4854.  
  4855. findbadptr        ;find me an alive baddy    
  4856.     ;uses baddy struture pointer A4
  4857.     ;returns baddy struture in A5
  4858.  
  4859. .badloop    move.l    (a4)+,a5    ;get baddy
  4860.     cmp.l    #0,a5
  4861.     beq    .no_bads
  4862.  
  4863.     ;check to see if baddy is alive
  4864.     cmp.b    #OKAY,bad_status(a5)
  4865.     bne    .badloop    ;cant hit him if baddy DEAD!
  4866.     
  4867.  
  4868.     move.l    #1,d0
  4869.     rts
  4870. .no_bads
  4871.     sub.l    #4,a4    #go down 1 please
  4872.     move.l    #0,d0
  4873.     rts
  4874.  
  4875. badtoplayxy        ;are we near each other?
  4876.     ;check PLAYER Vs BADDY    
  4877.     clr.l    d0
  4878.     clr.l    d1
  4879.     move.w    bad_x(a5),d0
  4880.     add.w    #16,d0
  4881.     cmp.w    play_xpos(a6),d0
  4882.     bgt    .pastme
  4883.     bra    .checkout
  4884. .pastme
  4885.     move.w    bad_x(a5),d0
  4886.     sub.w    #16,d0
  4887.     cmp.w    play_xpos(a6),d0
  4888.     bge    .checkout
  4889.     
  4890. .COLLISIONX
  4891.     clr.l    d0
  4892.     clr.l    d1
  4893.     move.w    bad_y(a5),d0
  4894.     add.w    #24,d0
  4895.     cmp.w    play_ypos(a6),d0
  4896.     bgt    .belowme
  4897.     bra    .checkout
  4898. .belowme
  4899.     move.w    bad_y(a5),d0
  4900.     sub.w    #16,d0
  4901.     cmp.w    play_ypos(a6),d0
  4902.     blt    .COLLISIONY
  4903.     bra    .checkout
  4904.  
  4905. .COLLISIONY
  4906.     move.l    #1,d0    ;hey ive hit somebody!
  4907.     rts
  4908. .checkout
  4909.     move.l    #0,d0    ;missed
  4910.     rts
  4911.     
  4912.     
  4913.  
  4914. blitcollplayer    ;blit player onto collision    
  4915.     ;player struct in a6
  4916.     
  4917.     move.l    a6,spare
  4918.     CALLGRAF    WaitBlit
  4919.     move.l    spare,a6
  4920.     
  4921.     move.w    #$ffff,$dff044    ;fwm
  4922.     move.w    #$ffff,$dff046    ;lwm
  4923.     move.w    #40-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  4924.     move.w    #scrwid-4,$dff066    ;mod D
  4925.     move.w    #0,$dff042    
  4926.  
  4927.     move.w    play_smooth(a6),d0    ;get smooth
  4928.     and.w    #$f000,d0
  4929.     or.w    #$09f0,d0
  4930.     move.w    d0,$dff040    
  4931.     
  4932.     move.l    collbase,a2        ;get coarse
  4933.     clr.l    d0
  4934.     clr.l    d1
  4935.     move.w    play_xpos(a6),d0
  4936.     move.w    play_ypos(a6),d1
  4937.     sub.w    #8,d1        ;player is 24 high
  4938.     mulu    #scrwid,d1
  4939.  
  4940.     and.w    #$fff0,d0    ;do corse scrol
  4941.     lsr.w    #3,d0
  4942.     add.w    d0,d1    ;got coarse
  4943.     
  4944.     add.l    d1,a2    ;worked out coarse
  4945.  
  4946.     move.l    a2,spare+4    ;save it for clear rtn
  4947.         
  4948.     move.l    Player1COLLBase,a3
  4949. ;    lea    playersCOLL,a3
  4950.     
  4951.     clr.l    d0
  4952.     clr.l    d1
  4953.     move.b    play_anim_style(a6),d0    ;get style
  4954.     mulu    #40*24,d0        ;get to anim set
  4955.     
  4956.     move.b    play_anim_frame(a6),d1    ;get frame
  4957.     lsl.l    #2,d1
  4958.     add.l    d1,d0
  4959.     add.l    d0,a3    ;add to player gfx
  4960.     
  4961.     move.l    a3,$dff050    ;get mask A
  4962.     move.l    a2,$dff054    ;dst D    screen
  4963.     move.w    #(24*1*64)+2,$dff058
  4964.  
  4965.     rts
  4966.  
  4967. clearcollplayer    ;clear player from collision    
  4968.     move.l    a6,spare
  4969.     CALLGRAF    WaitBlit
  4970.     move.l    spare,a6
  4971.     
  4972.     move.w    #$ffff,$dff044    ;fwm
  4973.     move.w    #$ffff,$dff046    ;lwm
  4974.     move.w    #40-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  4975.     move.w    #scrwid-4,$dff066    ;mod D
  4976.     move.w    #0,$dff042    
  4977.  
  4978.     move.w    #$0100,$dff040    
  4979.     
  4980.     move.l    spare+4,a2
  4981.     
  4982.     move.l    a2,$dff054    ;dst D    screen
  4983.     move.w    #(24*1*64)+2,$dff058
  4984.  
  4985.     rts
  4986.  
  4987. blitcollbaddy    ;blit baddy onto collision    
  4988.     ;baddy struct in a5
  4989.     
  4990.     move.l    a5,spare
  4991.     CALLGRAF    WaitBlit
  4992.     move.l    spare,a5
  4993.     
  4994.     move.w    #$ffff,$dff044    ;fwm
  4995.     move.w    #$ffff,$dff046    ;lwm
  4996.     move.w    #80-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  4997.     move.w    #scrwid-4,$dff066    ;mod D
  4998.     move.w    #0,$dff042    
  4999.  
  5000.     move.w    bad_smooth(a5),d0    ;get smooth
  5001.     and.w    #$f000,d0
  5002.     or.w    #$09f0,d0
  5003.     move.w    d0,$dff040    
  5004.     
  5005.     move.l    collbase,a2        ;get coarse
  5006.     clr.l    d0
  5007.     clr.l    d1
  5008.     move.w    bad_x(a5),d0
  5009.     move.w    bad_y(a5),d1
  5010.     mulu    #scrwid,d1
  5011.  
  5012.     and.w    #$fff0,d0    ;do corse scrol
  5013.     lsr.w    #3,d0
  5014.     add.w    d0,d1    ;got coarse
  5015.     
  5016.     add.l    d1,a2    ;worked out coarse
  5017.  
  5018.     move.l    a2,spare+4    ;save it for clear rtn
  5019.         
  5020.     move.l    Baddy1COLLBase,a3
  5021.  
  5022.     clr.l    d0
  5023.     move.b    bad_gfxnum(a5),d0
  5024. .findgfx
  5025.     cmp.l    #0,d0
  5026.     beq    .nogfx
  5027.     add.l    #80*1*16,a3
  5028.     dbra    d0,.findgfx
  5029. .nogfx
  5030.  
  5031.     clr.l    d0
  5032.     move.b    bad_anim(a5),d0    ;get anim no.
  5033.     
  5034.     ;figure out what gfk to display
  5035.     ;get direction to suss which gfks to use
  5036.     clr.l    d1
  5037.     lea    bad_an_rcnt(a5),a2    ;get actuall addr
  5038.     move.b    bad_an_off(a5),d1
  5039.     add.l    #1,a2        ;skip counter
  5040.     add.l    d1,a2        ;found bank!
  5041.     add.l    d0,a2        ;found char
  5042.     
  5043.     clr.l    d0
  5044.     move.b    (a2),d0        ;get char
  5045.     
  5046.     rol.l    #2,d0        ;make long!
  5047.     add.l    d0,a3        ;got baddy
  5048.  
  5049.     move.l    a3,$dff050    ;get mask A
  5050.     move.l    spare+4,$dff054    ;dst D    screen
  5051.     move.w    #(16*1*64)+2,$dff058
  5052.  
  5053.     rts
  5054.  
  5055. clearcollbaddy    ;clear baddy from collision    
  5056.     move.l    a5,spare
  5057.     CALLGRAF    WaitBlit
  5058.     move.l    spare,a5
  5059.     
  5060.     move.w    #$ffff,$dff044    ;fwm
  5061.     move.w    #$ffff,$dff046    ;lwm
  5062.     move.w    #80-4,$dff064    ;mod A .gfx map = 6 bytes. ball = 4
  5063.     move.w    #scrwid-4,$dff066    ;mod D
  5064.     move.w    #0,$dff042    
  5065.  
  5066.     move.w    #$0100,$dff040    
  5067.     
  5068.     move.l    spare+4,a2
  5069.     
  5070.     move.l    a2,$dff054    ;dst D    screen
  5071.     move.w    #(16*1*64)+2,$dff058
  5072.  
  5073.     rts
  5074. guntobadxy        ;are we near each other?
  5075.     ;check bullet(a1) Vs baddy(a5)
  5076.     clr.l    d0
  5077.     clr.l    d1
  5078.     move.w    bad_x(a5),d0
  5079.     add.w    #16,d0
  5080.     cmp.w    bull_xpos(a1),d0
  5081.     bgt    .pastme
  5082.     bra    .checkout
  5083. .pastme
  5084.     move.w    bad_x(a5),d0
  5085.     sub.w    #16,d0
  5086.     cmp.w    bull_xpos(a1),d0
  5087.     bge    .checkout
  5088.     
  5089. .COLLISIONX
  5090.     clr.l    d0
  5091.     clr.l    d1
  5092.     move.w    bad_y(a5),d0
  5093.     add.w    #12,d0
  5094.     cmp.w    bull_ypos(a1),d0
  5095.     bgt    .belowme
  5096.     bra    .checkout
  5097. .belowme
  5098.     move.w    bad_y(a5),d0
  5099.     sub.w    #12,d0
  5100.     cmp.w    bull_ypos(a1),d0
  5101.     blt    .COLLISIONY
  5102.     bra    .checkout
  5103.  
  5104. .COLLISIONY
  5105.     move.l    #1,d0    ;hey ive hit somebody!
  5106.     rts
  5107. .checkout
  5108.     move.l    #0,d0    ;missed
  5109.     rts
  5110.  
  5111. badtoplayblit    ;blit baddy on to collision
  5112.     ;collision minterm A and B = 0CC0 (Does not use D)
  5113.     ;if no collision clear temp
  5114.     ;%0000 1100 0000 0000 SRC AB
  5115.     ;%0000 1100 1100 0000 A and B
  5116.  
  5117.     move.w    #$ffff,_CUSTOM+bltafwm    ;fwm
  5118.     move.w    #$ffff,_CUSTOM+bltalwm    ;lwm
  5119.     move.w    #80-4,_CUSTOM+bltamod    ;mod A baddy collisiob
  5120.     move.w    #scrwid-4,_CUSTOM+bltbmod    ;mod B player collision
  5121.  
  5122.     clr.l    d0
  5123.     move.w    bad_smooth(a5),d0    ;get smooth
  5124.     and.w    #$f000,d0
  5125.     or.w    #$0cc0,d0
  5126.     
  5127.     move.w    d0,_CUSTOM+bltcon0    ;collision please
  5128.     move.w    #0,_CUSTOM+bltcon1
  5129.  
  5130.     move.l    collbase,a2        ;get coarse
  5131.     clr.l    d0
  5132.     clr.l    d1
  5133.     move.w    bad_x(a5),d0
  5134.     move.w    bad_y(a5),d1
  5135.     mulu    #scrwid,d1
  5136.  
  5137.     and.w    #$fff0,d0    ;do corse scrol
  5138.     lsr.w    #3,d0
  5139.     add.w    d0,d1    ;got coarse
  5140.     
  5141.     add.l    d1,a2    ;worked out coarse
  5142.     move.l    a2,_CUSTOM+bltbpt    ;baddy addr
  5143.  
  5144.  
  5145.     clr.l    d0
  5146.     ;find what gfk to use!!
  5147.     move.l    Baddy1COLLBase,a3
  5148.     move.b    bad_gfxnum(a1),d0
  5149. .findgfx
  5150.     cmp.l    #0,d0
  5151.     beq    .nogfx
  5152.     add.l    #80*1*16,a3
  5153.     dbra    d0,.findgfx
  5154. .nogfx
  5155.     
  5156.  
  5157.  
  5158.     clr.l    d0
  5159.     move.b    bad_anim(a5),d0    ;get anim no.
  5160.     
  5161.     ;figure out what gfk to display
  5162.     ;get direction to suss which gfks to use
  5163.     clr.l    d1
  5164.     lea    bad_an_rcnt(a5),a2    ;get actuall addr
  5165.     move.b    bad_an_off(a5),d1
  5166.     add.l    #1,a2        ;skip counter
  5167.     add.l    d1,a2        ;found bank!
  5168.     add.l    d0,a2        ;found char
  5169.     
  5170.     clr.l    d0
  5171.     move.b    (a2),d0        ;get char
  5172.     
  5173.     rol.l    #2,d0        ;make long!
  5174.     add.l    d0,a3        ;got baddy
  5175.     
  5176.     move.l    a3,_CUSTOM+bltapt    ;baddy gfk
  5177.  
  5178.     move.w    #(16*1*64)+2,_CUSTOM+bltsize    ;go for it
  5179.  
  5180.     move.l    a6,spare
  5181.     CALLGRAF    WaitBlit
  5182.     move.l    spare,a6
  5183.  
  5184.     btst    #13,_CUSTOM+dmaconr
  5185.     beq    .nocollision
  5186.     move.l    #0,d0        ;Got im
  5187.     rts
  5188. .nocollision
  5189.     move.l    #1,d0        ;missed!
  5190.     rts    
  5191.  
  5192.  
  5193. findbullptr        ;find me an alive bullet
  5194.     ;if its a lazer then dont do any collision
  5195.     cmp.b    #WeapLazer,bull_gun(a1)
  5196.     beq    .lazer
  5197.     
  5198.     ;check to see if bullet is alive
  5199.     cmp.b    #OKAY,bull_status(a1)
  5200.     beq    .okay
  5201.  
  5202. .lazer    add.l    #bullet_nd-bullet,a1    ;next bullet
  5203.     add.b    #1,d5
  5204.     cmp.b    #bullet_max-1,d5
  5205.     ble    findbullptr
  5206.     ;no bullets!
  5207.     sub.l    #bullet_nd-bullet,a1    ;pre bullet
  5208.     move.l    #0,d0
  5209.     rts
  5210.     
  5211.  
  5212. .okay    move.l    #$1,d0        ;got 1
  5213.     rts
  5214.  
  5215. bulltoplayxy    ;are we near each other?
  5216.     clr.l    d0
  5217.     clr.l    d1
  5218.     move.w    bull_xpos(a1),d0
  5219.     add.w    #16,d0
  5220.     cmp.w    play_xpos(a6),d0
  5221.     bgt    .pastme
  5222.     bra    .checkout
  5223. .pastme
  5224.     move.w    bull_xpos(a1),d0
  5225.     sub.w    #16,d0
  5226.     cmp.w    play_xpos(a6),d0
  5227.     bge    .checkout
  5228.     
  5229. .COLLISIONX
  5230.     clr.l    d0
  5231.     clr.l    d1
  5232.     move.w    bull_ypos(a1),d0
  5233.     add.w    #16,d0
  5234.     cmp.w    play_ypos(a6),d0
  5235.     bgt    .belowme
  5236.     bra    .checkout
  5237. .belowme
  5238.     move.w    bull_ypos(a1),d0
  5239.     sub.w    #16,d0
  5240.     cmp.w    play_ypos(a6),d0
  5241.     blt    .COLLISIONY
  5242.     bra    .checkout
  5243.  
  5244. .COLLISIONY
  5245.     move.b    #1,d0    ;hey ive hit somebody!
  5246.     rts
  5247.     
  5248. .checkout
  5249.     move.b    #0,d0    ;missed
  5250.     rts
  5251.  
  5252. bulltoplayblit    ;blit bullet on to collision
  5253.     ;collision minterm A and B = 0CC0 (Does not use D)
  5254.     ;if no collision clear temp
  5255.     ;%0000 1100 0000 0000 SRC AB
  5256.     ;%0000 1100 1100 0000 A and B
  5257.  
  5258.     move.w    #$ffff,_CUSTOM+bltafwm    ;fwm
  5259.     move.w    #$ffff,_CUSTOM+bltalwm    ;lwm
  5260.     move.w    #40-4,_CUSTOM+bltamod    ;mod A bullet collisiob
  5261.     move.w    #scrwid-4,_CUSTOM+bltbmod    ;mod B player collision
  5262.  
  5263.     clr.l    d0
  5264.     move.w    bull_smooth(a1),d0    ;get smooth
  5265.     and.w    #$f000,d0
  5266.     or.w    #$0cc0,d0
  5267.     
  5268.     move.w    d0,_CUSTOM+bltcon0    ;collision please
  5269.     move.w    #0,_CUSTOM+bltcon1
  5270.  
  5271.     move.l    collbase,a2        ;get coarse
  5272.     clr.l    d0
  5273.     clr.l    d1
  5274.     move.w    bull_xpos(a1),d0
  5275.     move.w    bull_ypos(a1),d1
  5276.     mulu    #scrwid,d1
  5277.  
  5278.     and.w    #$fff0,d0    ;do corse scrol
  5279.     lsr.w    #3,d0
  5280.     add.w    d0,d1    ;got coarse
  5281.     
  5282.     add.l    d1,a2    ;worked out coarse
  5283.     move.l    a2,_CUSTOM+bltbpt    ;baddy addr
  5284.  
  5285.  
  5286.     ;find what gfk to use!!
  5287.     clr.l    d0
  5288.     move.b    bull_wantgo(a1),d0    ;find what gfk to use
  5289.     btst    #BOBB_LEFT,d0
  5290.     beq    .goingr
  5291.     move.l    #4,d0
  5292.     bra    .skip
  5293. .goingr
  5294.     clr.l    d0
  5295. .skip        
  5296.     move.l    Bullet1COLLBase,a3
  5297.     clr.l    d1
  5298.     move.w    bull_gfk(a1),d1    ;weird (a2)
  5299.  
  5300.     ;if d1 > 40 then add 40*16*5,a3
  5301. .loopin
  5302.     cmp.b    #40,d1
  5303.     blt    .ok
  5304.     add.l    #80*16*5,a3
  5305.     sub.l    #40,d1
  5306.     bra    .loopin
  5307. .ok
  5308.     add.l    d1,a3
  5309.  
  5310.     add.l    d0,a3
  5311.     
  5312.     move.l    a3,_CUSTOM+bltapt    ;baddy gfk
  5313.  
  5314.     move.w    #(16*1*64)+2,_CUSTOM+bltsize    ;go for it
  5315.  
  5316.     move.l    a6,spare
  5317.     CALLGRAF    WaitBlit
  5318.     move.l    spare,a6
  5319.  
  5320.     btst    #13,_CUSTOM+dmaconr
  5321.     beq    .nocollision
  5322.     move.l    #0,d0        ;got im
  5323.     rts
  5324. .nocollision
  5325.     move.l    #1,d0        ;missed!
  5326.     rts
  5327.  
  5328. bulltobadblit    ;blit bullet on to collision
  5329.     ;collision minterm A and B = 0CC0 (Does not use D)
  5330.     ;if no collision clear temp
  5331.     ;%0000 1100 0000 0000 SRC AB
  5332.     ;%0000 1100 1100 0000 A and B
  5333.  
  5334.     move.w    #$ffff,_CUSTOM+bltafwm    ;fwm
  5335.     move.w    #$ffff,_CUSTOM+bltalwm    ;lwm
  5336.     move.w    #40-4,_CUSTOM+bltamod    ;mod A bullet collisiob
  5337.     move.w    #scrwid-4,_CUSTOM+bltbmod    ;mod B baddy collision
  5338.  
  5339.     clr.l    d0
  5340.     move.w    bull_smooth(a1),d0    ;get smooth
  5341.     and.w    #$f000,d0
  5342.     or.w    #$0cc0,d0
  5343.     
  5344.     move.w    d0,_CUSTOM+bltcon0    ;collision please
  5345.     move.w    #0,_CUSTOM+bltcon1
  5346.  
  5347.     move.l    collbase,a2        ;get coarse
  5348.     clr.l    d0
  5349.     clr.l    d1
  5350.     move.w    bull_xpos(a1),d0
  5351.     move.w    bull_ypos(a1),d1
  5352.     mulu    #scrwid,d1
  5353.  
  5354.     and.w    #$fff0,d0    ;do corse scrol
  5355.     lsr.w    #3,d0
  5356.     add.w    d0,d1    ;got coarse
  5357.     
  5358.     add.l    d1,a2    ;worked out coarse
  5359.     move.l    a2,_CUSTOM+bltbpt    ;baddy addr
  5360.  
  5361.  
  5362.     ;find what gfk to use!!
  5363.     clr.l    d0
  5364.     move.b    bull_wantgo(a1),d0    ;find what gfk to use
  5365.     btst    #BOBB_LEFT,d0
  5366.     beq    .goingr
  5367.     move.l    #4,d0
  5368.     bra    .skip
  5369. .goingr
  5370.     clr.l    d0
  5371. .skip        
  5372.     move.l    Bullet1COLLBase,a3
  5373.     clr.l    d1
  5374.     move.w    bull_gfk(a1),d1
  5375.  
  5376.     ;if d1 > 40 then add 40*16*5,a3
  5377. .loopin
  5378.     cmp.b    #40,d1
  5379.     blt    .ok
  5380.     add.l    #80*16*5,a3
  5381.     sub.l    #40,d1
  5382.     bra    .loopin
  5383. .ok
  5384.     add.l    d1,a3
  5385.  
  5386.     add.l    d0,a3
  5387.     
  5388.     move.l    a3,_CUSTOM+bltapt    ;baddy gfk
  5389.  
  5390.     move.w    #(16*1*64)+2,_CUSTOM+bltsize    ;go for it
  5391.  
  5392.     move.l    a6,spare
  5393.     CALLGRAF    WaitBlit
  5394.     move.l    spare,a6
  5395.  
  5396.     btst    #13,_CUSTOM+dmaconr
  5397.     beq    .nocollision
  5398.     move.l    #0,d0        ;got im
  5399.     rts
  5400. .nocollision
  5401.     move.l    #1,d0        ;missed!
  5402.     rts
  5403.  
  5404. AllocTemps        ;alloc all the tempory storage for gfx
  5405.  
  5406.     ;allocate bad_temp1
  5407.     clr.l    d0        ;allocate some memory for it!
  5408.     move.l    #4*16*5*bad_max,d0
  5409.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5410.     CALLEXEC    AllocMem
  5411.     move.l    d0,bad_temp1Base
  5412.  
  5413.     ;allocate bad_temp2
  5414.     clr.l    d0        ;allocate some memory for it!
  5415.     move.l    #4*16*5*bad_max,d0
  5416.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5417.     CALLEXEC    AllocMem
  5418.     move.l    d0,bad_temp2Base
  5419.  
  5420.     ;allocate player_temp1
  5421.     clr.l    d0        ;allocate some memory for it!
  5422.     move.l    #4*24*5*players_max,d0
  5423.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5424.     CALLEXEC    AllocMem
  5425.     move.l    d0,player_temp1Base
  5426.  
  5427.     ;allocate player_temp2
  5428.     clr.l    d0        ;allocate some memory for it!
  5429.     move.l    #4*24*5*players_max,d0
  5430.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5431.     CALLEXEC    AllocMem
  5432.     move.l    d0,player_temp2Base
  5433.  
  5434.     ;allocate bullet_temp1
  5435.     clr.l    d0        ;allocate some memory for it!
  5436.     move.l    #4*16*5*bullet_max,d0
  5437.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5438.     CALLEXEC    AllocMem
  5439.     move.l    d0,bullet_temp1Base
  5440.  
  5441.     ;allocate bullet_temp2
  5442.     clr.l    d0        ;allocate some memory for it!
  5443.     move.l    #4*16*5*bullet_max,d0
  5444.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5445.     CALLEXEC    AllocMem
  5446.     move.l    d0,bullet_temp2Base
  5447.  
  5448.     ;allocate gun_temp1
  5449.     clr.l    d0        ;allocate some memory for it!
  5450.     move.l    #4*16*5*gun_max,d0
  5451.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5452.     CALLEXEC    AllocMem
  5453.     move.l    d0,gun_temp1Base
  5454.  
  5455.     ;allocate gun_temp2
  5456.     clr.l    d0        ;allocate some memory for it!
  5457.     move.l    #4*16*5*gun_max,d0
  5458.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  5459.     CALLEXEC    AllocMem
  5460.     move.l    d0,gun_temp2Base
  5461.  
  5462.     ;allocate lazertemp
  5463.     clr.l    d0        ;allocate some memory for it!
  5464.     move.l    #scrwid*(16*4)*5,d0
  5465.     move.l    #MEMF_CLEAR,d1
  5466.     CALLEXEC    AllocMem
  5467.     move.l    d0,lazertempBase
  5468.  
  5469.     rts
  5470. FreeTemps
  5471.     ;free up badtemp1
  5472.     move.l    #4*16*5*bad_max,d0
  5473.     move.l    bad_temp1Base,a1
  5474.     CALLEXEC    FreeMem
  5475.  
  5476.     ;free up badtemp2
  5477.     move.l    #4*16*5*bad_max,d0
  5478.     move.l    bad_temp2Base,a1
  5479.     CALLEXEC    FreeMem
  5480.  
  5481.     ;free up playertemp1
  5482.     move.l    #4*24*5*players_max,d0
  5483.     move.l    player_temp1Base,a1
  5484.     CALLEXEC    FreeMem
  5485.  
  5486.     ;free up playertemp2
  5487.     move.l    #4*24*5*players_max,d0
  5488.     move.l    player_temp2Base,a1
  5489.     CALLEXEC    FreeMem
  5490.  
  5491.     ;free up bullettemp1
  5492.     move.l    #4*16*5*bullet_max,d0
  5493.     move.l    bullet_temp1Base,a1
  5494.     CALLEXEC    FreeMem
  5495.  
  5496.     ;free up bullettemp2
  5497.     move.l    #4*16*5*bullet_max,d0
  5498.     move.l    bullet_temp2Base,a1
  5499.     CALLEXEC    FreeMem
  5500.  
  5501.     ;free up guntemp1
  5502.     move.l    #4*16*5*gun_max,d0
  5503.     move.l    gun_temp1Base,a1
  5504.     CALLEXEC    FreeMem
  5505.  
  5506.     ;free up guntemp2
  5507.     move.l    #4*16*5*gun_max,d0
  5508.     move.l    gun_temp2Base,a1
  5509.     CALLEXEC    FreeMem
  5510.  
  5511.     ;free up lazertemp
  5512.     move.l    #scrwid*(16*4)*5,d0
  5513.     move.l    lazertempBase,a1
  5514.     CALLEXEC    FreeMem
  5515.  
  5516.     rts
  5517.  
  5518. FreeGfxMem
  5519.     move.l    CharSize,d0
  5520.     move.l    CharBase,a1
  5521.     CALLEXEC    FreeMem
  5522.     
  5523.     move.l    MaskSize,d0
  5524.     move.l    MaskBase,a1
  5525.     CALLEXEC    FreeMem
  5526.  
  5527.     move.l    CmapSize,d0
  5528.     move.l    CmapBase,a1
  5529.     CALLEXEC    FreeMem
  5530.  
  5531.     move.l    LDSize,d0
  5532.     move.l    LDBase,a1
  5533.     CALLEXEC    FreeMem
  5534.  
  5535.     move.l    BackSize,d0
  5536.     move.l    BackBase,a1
  5537.     CALLEXEC    FreeMem
  5538.  
  5539.     move.l    TitleSize,d0
  5540.     move.l    TitleBase,a1
  5541.     CALLEXEC    FreeMem
  5542.  
  5543.     move.l    FontSize,d0
  5544.     move.l    FontBase,a1
  5545.     CALLEXEC    FreeMem
  5546.  
  5547.     move.l    Baddy1Size,d0
  5548.     move.l    Baddy1Base,a1
  5549.     CALLEXEC    FreeMem
  5550.  
  5551.     move.l    Baddy1COLLSize,d0
  5552.     move.l    Baddy1COLLBase,a1
  5553.     CALLEXEC    FreeMem
  5554.  
  5555.     move.l    Player1Size,d0
  5556.     move.l    Player1Base,a1
  5557.     CALLEXEC    FreeMem
  5558.  
  5559.     move.l    Player1COLLSize,d0
  5560.     move.l    Player1COLLBase,a1
  5561.     CALLEXEC    FreeMem
  5562.  
  5563.     move.l    Bullet1Size,d0
  5564.     move.l    Bullet1Base,a1
  5565.     CALLEXEC    FreeMem
  5566.  
  5567.     move.l    Bullet1COLLSize,d0
  5568.     move.l    Bullet1COLLBase,a1
  5569.     CALLEXEC    FreeMem
  5570.     
  5571.     rts
  5572. LoadNProcess
  5573.     ;first load in the IntSet File From T dir
  5574.     bsr    LoadIntSet
  5575.  
  5576.     bsr    LoadChar    ;search IntSet for Char filename. load & process
  5577.     bsr    LoadMask    ;search IntSet for Mask filename. load & process
  5578.     bsr    LoadCmap    ;search IntSet for Cmap filename. load & process
  5579.  
  5580.     bsr    LoadLev    ;search IntSet for level filename. load & process
  5581.     bsr    LoadBack    ;search IntSet for backdrop filename. load & process
  5582.     bsr    LoadTitle    ;search intset for title screen (320*104)
  5583.     bsr    LoadFont    ;search intset for font (832*48)
  5584.     bsr    LoadBaddy1    ;search IntSet for baddy filename. load & process
  5585.     
  5586.     bsr    LoadPlayer1    ;search IntSet for player1 filename. load & process
  5587.     bsr    LoadBullet1    ;search IntSet for bullet1 filename. load & process
  5588.     ;search through it until you find CHAR=
  5589.     rts
  5590. LoadChar
  5591.     lea    charascii,a0
  5592.     bsr    FindAscii        ;search through IntSet until you Find CHAR=
  5593.     
  5594.                 ;find ascii returns the filename its found in A0
  5595.                 ;* NOTE * the file name is not ZERO terminated
  5596.                 ;with a bit of luck its $0a terminated
  5597.  
  5598.     bsr    getfname
  5599.  
  5600.     move.l    #40960,CharSize
  5601.     
  5602.     ;allocate some memory for the picture
  5603.     clr.l    d0        ;allocate some memory for it!
  5604.     move.l    CharSize,d0
  5605.     move.l    #MEMF_CHIP|MEMF_CLEAR,d1
  5606.     CALLEXEC    AllocMem
  5607.     move.l    d0,CharBase
  5608.  
  5609.     ;load as an iff file!
  5610.     bsr    convertchar
  5611.     bsr    ilbm_to_twi4
  5612.     ;FileBase    is the start of the ilbm pic
  5613. ;    lea    FileName,a0    
  5614. ;    bsr    LoadChipData
  5615. ;    move.l    FileSize,CharSize
  5616. ;    move.l    FileBase,CharBase    
  5617.     rts
  5618.  
  5619. ilbm_to_twi4
  5620.     move.l    FileBase,a3    ;get source
  5621.     move.l    CharBase,a1    ;get dest
  5622. ;    add.l    #16*5*2,a1    ;get past blank first char!
  5623.     
  5624.     ;source is 40*5 for bit1
  5625.     ;dest is 2*5 for bit1
  5626.     clr.l    d7
  5627.     move.w    #13,d5        ;do 13*20 = 260!
  5628. .loop3
  5629.     clr.l    d6
  5630.     move.l    a3,a2
  5631. .loop
  5632.     move.l    a2,a0
  5633.     move.w    #16-1,d4
  5634. .loop2
  5635.     move.w    (a0),(a1)        ;copy 1 plane
  5636.     move.w    40(a0),2(a1)    ;copy 1 plane
  5637.     move.w    80(a0),4(a1)    ;copy 1 plane
  5638.     move.w    120(a0),6(a1)    ;copy 1 plane
  5639.     move.w    160(a0),8(a1)    ;copy 1 plane
  5640.     
  5641.     add.l    #40*5,a0    ;next line please
  5642.     add.l    #2*5,a1    ;next line please
  5643.     dbra    d4,.loop2
  5644.     
  5645.     add.w    #1,d7    ;char counter
  5646.     cmp.w    #255,d7
  5647.     beq    .out    ;finish when 256
  5648.         
  5649.     add.l    #2,a2
  5650.     add.w    #1,d6
  5651.     cmp.w    #20,d6
  5652.     bne    .loop    ;do a line of chars
  5653.     add.l    #16*40*5,a3
  5654.     dbra    d5,.loop3
  5655.     
  5656. .out
  5657.     ;now free up the iff mem...
  5658.     ;free up the memory!
  5659.     move.l    #42*5*256,d0
  5660.     move.l    FileBase,a1
  5661.     CALLEXEC    FreeMem
  5662.  
  5663.  
  5664.     rts
  5665.  
  5666.  
  5667. convertchar
  5668.  
  5669.     ;This is an IFF piccy.
  5670.     ;We want a bitmap one please so lets use the iff library to load
  5671.     
  5672.     lea    FileName,a0    
  5673.     move.l    #IFFL_MODE_READ,d0
  5674.     CALLIFF    OpenIFF
  5675.     move.l    d0,iffhandle
  5676.     
  5677.     lea    bitmap,a0
  5678.     move.l    #$05,d0        ;depth
  5679.     move.l    #320*5,d1        ;width
  5680.     move.l    #256,d2        ;height
  5681.     CALLGRAF    InitBitMap
  5682.  
  5683.     ;allocate some memory for the picture
  5684.     clr.l    d0        ;allocate some memory for it!
  5685.     move.l    #42*5*256,d0
  5686.     move.l    #MEMF_CLEAR,d1
  5687.     CALLEXEC    AllocMem
  5688.     move.l    d0,FileBase
  5689.     
  5690.     ;now copy the pointer into the bitmap structure
  5691.     move.l    #5-1,d7
  5692.     move.l    FileBase,a0
  5693.     lea    bitmap,a1
  5694. .back    move.l    a0,bm_Planes(a1)
  5695.     add.l    #40,a0
  5696.     add.l    #4,a1    ;next long please
  5697.     dbra    d7,.back
  5698.     
  5699.  
  5700.     move.l    iffhandle,a1
  5701.     lea    bitmap,a0
  5702.     CALLIFF    DecodePic
  5703.     
  5704.     move.l    iffhandle,a1
  5705.     CALLIFF    CloseIFF    
  5706.     
  5707.     
  5708.     rts
  5709.  
  5710. LoadMask
  5711.     ;create the mask for the chars (dont be so lame)
  5712.     move.l    #8192,MaskSize
  5713.     move.l    MaskSize,d0
  5714.     move.l    #MEMF_CHIP|MEMF_CLEAR,d1
  5715.     CALLEXEC    AllocMem
  5716.     move.l    d0,MaskBase
  5717.     
  5718.     move.l    CharBase,a0
  5719.     move.l    MaskBase,a1
  5720.     move.l    #256-1,d7
  5721. .loop2    
  5722.     move.l    #16-1,d6
  5723. .loop
  5724.     clr.l    d0
  5725.     move.w    (a0)+,d0    ;1bp
  5726.     or.w    (a0)+,d0    ;2bp
  5727.     or.w    (a0)+,d0    ;3bp
  5728.     or.w    (a0)+,d0    ;4bp
  5729.     or.w    (a0)+,d0    ;5bp
  5730.     move.w    d0,(a1)+
  5731.     dbra    d6,.loop
  5732.     dbra    d7,.loop2
  5733.     
  5734.     
  5735.     rts
  5736. LoadCmap
  5737.     ;this loads an iff file with the cmap in it!!!!
  5738.     lea    cmapascii,a0
  5739.     bsr    FindAscii    
  5740.     bsr    getfname
  5741.     lea    FileName,a0    
  5742.     move.l    #IFFL_MODE_READ,d0
  5743.     CALLIFF    OpenIFF
  5744.     move.l    d0,iffhandle
  5745.  
  5746.     move.l    iffhandle,a1        ;iff handle ??
  5747.     lea    colours,a0
  5748.     CALLIFF    GetColorTab
  5749.  
  5750.     move.l    iffhandle,a1
  5751.     CALLIFF    CloseIFF    
  5752.     
  5753.  
  5754.     rts
  5755. LoadLev
  5756.     ;this loads in 10 levels complete with baddy movement data.
  5757.     ;and stores it in LDSize,LDBase
  5758.         
  5759.     ;okay this is difficult. grab levelnum var.
  5760.     ;and create an ascii number for it.
  5761.     ;then put it on top of the = and put the = after
  5762.     ;i.e.
  5763.     ;LEVEL=
  5764.     ;LEVEL01=
  5765.     
  5766.     ;copy level to scratch so we can add the number to it
  5767.     lea    levascii,a0
  5768.     lea    scratch,a1
  5769. .copy    move.b    (a0)+,(a1)+
  5770.     bne    .copy
  5771.  
  5772.     ;go backwards until you find the =
  5773. .back    cmp.b    #"=",-(a1)
  5774.     bne    .back
  5775.         
  5776.     clr.l    d0
  5777.     move.b    LevelNum,d0
  5778.     move.l    a1,a0
  5779.     bsr    numtoasc
  5780.     move.b    #"=",(a0)+        ;put the = back on
  5781.     move.b    #0,(a0)+        ;terminate please
  5782.  
  5783.     lea    scratch,a0
  5784.     bsr    FindAscii    
  5785.     bsr    getfname
  5786.     lea    FileName,a0    
  5787.     bsr    LoadNormData
  5788.     move.l    FileSize,LDSize
  5789.     move.l    FileBase,LDBase    
  5790.     lea    lev1ascii,a2    (10 bytes)
  5791.  
  5792. FindLev
  5793.     ;thats loaded the data in for 10 levels!
  5794.     ;set up pointer to first level please
  5795.     
  5796.     move.l    LDBase,a1
  5797.     move.l    a1,d0
  5798.     add.l    LDSize,d0        ;go max size
  5799. .loop    
  5800.     move.l    #9-1,d7        ;how many chars
  5801.     move.l    a2,a0    (10 bytes)
  5802.     cmp.l    d0,a1
  5803.     bge    .lost
  5804.     cmp.b    (a0)+,(a1)+        ;are they the same?
  5805.     bne    .loop        ;no
  5806.     ;groovy, ive found a match
  5807. .match    cmp.b    (a0)+,(a1)+
  5808.     bne    .loop
  5809.     dbra    d7,.match
  5810.     move.l    a1,LevBase
  5811.  
  5812.     ;now find a pointer to the first baddy    
  5813.  
  5814.     move.l    LevBase,a1
  5815.     move.l    LDBase,d0
  5816.     add.l    LDSize,d0        ;go max size
  5817. .loop2
  5818.     move.l    #7-1,d7        ;how many chars
  5819.     lea    bad1ascii,a0    (8 bytes)
  5820.     cmp.l    d0,a1
  5821.     bge    .lost
  5822.     cmp.b    (a0)+,(a1)+        ;are they the same?
  5823.     bne    .loop2        ;no
  5824.     ;groovy, ive found a match
  5825. .match2    cmp.b    (a0)+,(a1)+
  5826.     bne    .loop2
  5827.     dbra    d7,.match2
  5828.     move.l    a1,BadBase
  5829.     
  5830.     rts
  5831. .lost    ;cant find the level!!!!
  5832.     ;**** PANIC *******
  5833.     rts
  5834. LoadBack
  5835.     ;use levelnum to get the backdrop number!
  5836.     ;copy level to scratch so we can add the number to it
  5837.     lea    backascii,a0
  5838.     lea    scratch,a1
  5839. .copy    move.b    (a0)+,(a1)+
  5840.     bne    .copy
  5841.  
  5842.     ;go backwards until you find the =
  5843. .back    cmp.b    #"=",-(a1)
  5844.     bne    .back
  5845.         
  5846.     clr.l    d0
  5847.     move.b    LevelNum,d0
  5848.     move.l    a1,a0
  5849.     bsr    numtoasc
  5850.     move.b    #"=",(a0)+        ;put the = back on
  5851.     move.b    #0,(a0)+        ;terminate please
  5852.  
  5853.     lea    scratch,a0
  5854.     bsr    FindAscii    
  5855.     bsr    getfname
  5856.     
  5857.     bsr    ConvertBackDrop
  5858.  
  5859.     rts
  5860. ConvertBackDrop
  5861.  
  5862.     ;This is an IFF piccy.
  5863.     ;We want a bitmap one please so lets use the iff library to load
  5864.     
  5865.     lea    FileName,a0    
  5866.     move.l    #IFFL_MODE_READ,d0
  5867.     CALLIFF    OpenIFF
  5868.     move.l    d0,iffhandle
  5869.     
  5870.     lea    bitmap,a0
  5871.     move.l    #$05,d0        ;depth
  5872.     move.l    #320*5,d1        ;width
  5873.     move.l    #256,d2        ;height
  5874.     CALLGRAF    InitBitMap
  5875.  
  5876.     ;allocate some memory for the picture
  5877.     clr.l    d0        ;allocate some memory for it!
  5878.     move.l    BackSize,d0
  5879.     move.l    #MEMF_CLEAR,d1
  5880.     CALLEXEC    AllocMem
  5881.     move.l    d0,BackBase
  5882.     
  5883.     ;now copy the pointer into the bitmap structure
  5884.     move.l    #5-1,d7
  5885.     move.l    BackBase,a0
  5886.     lea    bitmap,a1
  5887. .back    move.l    a0,bm_Planes(a1)
  5888.     add.l    #40,a0
  5889.     add.l    #4,a1    ;next long please
  5890.     dbra    d7,.back
  5891.     
  5892.  
  5893.     move.l    iffhandle,a1
  5894.     lea    bitmap,a0
  5895.     CALLIFF    DecodePic
  5896.     
  5897.     move.l    iffhandle,a1
  5898.     CALLIFF    CloseIFF    
  5899.     
  5900.     
  5901.     rts
  5902.  
  5903. LoadTitle
  5904.     lea    titascii,a0
  5905.     bsr    FindAscii    
  5906.     bsr    getfname
  5907.     
  5908.     ;This is an IFF piccy.
  5909.     ;We want a bitmap one please so lets use the iff library to load
  5910.     
  5911.     lea    FileName,a0    
  5912.     move.l    #IFFL_MODE_READ,d0
  5913.     CALLIFF    OpenIFF
  5914.     move.l    d0,iffhandle
  5915.     
  5916.     lea    bitmap,a0
  5917.     move.l    #$05,d0        ;depth
  5918.     move.l    #320*5,d1        ;width
  5919.     move.l    #104,d2        ;height
  5920.     CALLGRAF    InitBitMap
  5921.  
  5922.     ;allocate some memory for the picture
  5923.     clr.l    d0        ;allocate some memory for it!
  5924.     move.l    TitleSize,d0
  5925.     move.l    #MEMF_CLEAR,d1
  5926.     CALLEXEC    AllocMem
  5927.     move.l    d0,TitleBase
  5928.     
  5929.     ;now copy the pointer into the bitmap structure
  5930.     move.l    #5-1,d7
  5931.     move.l    TitleBase,a0
  5932.     lea    bitmap,a1
  5933. .back    move.l    a0,bm_Planes(a1)
  5934.     add.l    #40,a0
  5935.     add.l    #4,a1    ;next long please
  5936.     dbra    d7,.back
  5937.  
  5938.     move.l    iffhandle,a1
  5939.     lea    bitmap,a0
  5940.     CALLIFF    DecodePic
  5941.     
  5942.     move.l    iffhandle,a1
  5943.     CALLIFF    CloseIFF    
  5944.     
  5945.     rts
  5946.  
  5947. LoadFont
  5948.     lea    fontascii,a0
  5949.     bsr    FindAscii    
  5950.     bsr    getfname
  5951.     
  5952.     ;This is an IFF piccy.
  5953.     ;We want a bitmap one please so lets use the iff library to load
  5954.     
  5955.     lea    FileName,a0    
  5956.     move.l    #IFFL_MODE_READ,d0
  5957.     CALLIFF    OpenIFF
  5958.     move.l    d0,iffhandle
  5959.     
  5960.     lea    bitmap,a0
  5961.     move.l    #$05,d0        ;depth
  5962.     move.l    #832*5,d1    ;width
  5963.     move.l    #48,d2        ;height
  5964.     CALLGRAF    InitBitMap
  5965.  
  5966.     ;allocate some memory for the picture
  5967.     clr.l    d0        ;allocate some memory for it!
  5968.     move.l    FontSize,d0
  5969.     move.l    #MEMF_CLEAR,d1
  5970.     CALLEXEC    AllocMem
  5971.     move.l    d0,FontBase
  5972.     
  5973.     ;now copy the pointer into the bitmap structure
  5974.     move.l    #5-1,d7
  5975.     move.l    FontBase,a0
  5976.     lea    bitmap,a1
  5977. .back    move.l    a0,bm_Planes(a1)
  5978.     add.l    #104,a0
  5979.     add.l    #4,a1    ;next long please
  5980.     dbra    d7,.back
  5981.  
  5982.     move.l    iffhandle,a1
  5983.     lea    bitmap,a0
  5984.     CALLIFF    DecodePic
  5985.     
  5986.     move.l    iffhandle,a1
  5987.     CALLIFF    CloseIFF    
  5988.     
  5989.     rts
  5990.  
  5991. LoadBaddy1
  5992.     lea    baddyascii,a0
  5993.     lea    scratch,a1
  5994. .copy    move.b    (a0)+,(a1)+
  5995.     bne    .copy
  5996.  
  5997.     ;go backwards until you find the =
  5998. .back    cmp.b    #"=",-(a1)
  5999.     bne    .back
  6000.         
  6001.     clr.l    d0
  6002.     move.b    #1,d0    ;** baddy NUMBER **
  6003.     move.l    a1,a0
  6004.     bsr    numtoasc
  6005.     move.b    #"=",(a0)+        ;put the = back on
  6006.     move.b    #0,(a0)+        ;terminate please
  6007.  
  6008.     lea    scratch,a0
  6009.     bsr    FindAscii    
  6010.     bsr    getfname
  6011.  
  6012.     ;allocate some memory for the picture
  6013.     clr.l    d0        ;allocate some memory for it!
  6014.     move.l    Baddy1Size,d0
  6015.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  6016.     CALLEXEC    AllocMem
  6017.     move.l    d0,Baddy1Base
  6018.  
  6019.     move.l    Baddy1Size,BaddySize
  6020.     move.l    Baddy1Base,BaddyBase
  6021.  
  6022.     bsr    ConvertBaddy
  6023.     
  6024.     ;Convert the collision plane, so jump to it
  6025.  
  6026.     ;allocate some memory for the collision plane
  6027.     clr.l    d0        ;allocate some memory for it!
  6028.     move.l    Baddy1COLLSize,d0
  6029.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  6030.     CALLEXEC    AllocMem
  6031.     move.l    d0,Baddy1COLLBase
  6032.  
  6033.     move.l    Baddy1COLLSize,BaddyCOLLSize
  6034.     move.l    Baddy1COLLBase,BaddyCOLLBase
  6035.     
  6036.     bsr    ConvertBaddyColl
  6037.         
  6038.     rts
  6039.  
  6040. ConvertBaddyColl
  6041.     move.l    BaddyBase,a0    ;source
  6042.     move.l    BaddyCOLLBase,a1    ;dest
  6043.     
  6044.     ;640 or next 640 or next 640 or next 640 or next 640 = COLL
  6045.  
  6046.     move.l    #baddygfx-1,d5        ;no. of baddies
  6047. .loop3    
  6048.  
  6049.     move.l    #16-1,d6        ;copy 16 rows or 1 char
  6050. .loop2    
  6051.     move.l    a0,a2        ;save for later
  6052.     move.l    #40-1,d7    ;copy 1 row
  6053. .loop
  6054.     move.w    (a1),d0
  6055.     or.w    (a2),d0        ;or 1st bitplane
  6056.     or.w    80(a2),d0        ;or 2nd bitplane
  6057.     or.w    160(a2),d0        ;or 3rd bitplane
  6058.     or.w    240(a2),d0        ;or 4th bitplane
  6059.     or.w    320(a2),d0        ;or 5th bitplane
  6060.     move.w    d0,(a1)
  6061.     add.l    #2,a2
  6062.     add.l    #2,a1    
  6063.     dbra    d7,.loop
  6064.     add.l    #80*5,a0        ;next row please
  6065.     dbra    d6,.loop2
  6066.     add.l    #16*80*5,a0        ;skip the mask gfk please
  6067.     dbra    d5,.loop3
  6068.  
  6069.     rts
  6070.  
  6071. ConvertBaddy    ;Load N Convert IFF piccy of baddies
  6072.     lea    FileName,a0    
  6073.     move.l    #IFFL_MODE_READ,d0
  6074.     CALLIFF    OpenIFF
  6075.     move.l    d0,iffhandle
  6076.     
  6077.     lea    bitmap,a0
  6078.     move.l    #$05,d0        ;depth
  6079.     move.l    #640*5,d1        ;width
  6080.     move.l    #baddygfx*32,d2        ;height
  6081.     CALLGRAF    InitBitMap
  6082.     
  6083.     ;now copy the pointer into the bitmap structure
  6084.     move.l    #5-1,d7
  6085.     move.l    BaddyBase,a0
  6086.     lea    bitmap,a1
  6087. .back    move.l    a0,bm_Planes(a1)
  6088.     add.l    #80,a0
  6089.     add.l    #4,a1    ;next long please
  6090.     dbra    d7,.back
  6091.  
  6092.     move.l    iffhandle,a1
  6093.     lea    bitmap,a0
  6094.     CALLIFF    DecodePic
  6095.     
  6096.     move.l    iffhandle,a1
  6097.     CALLIFF    CloseIFF    
  6098.     
  6099.     
  6100.     rts
  6101.  
  6102. ConvertPlayerColl
  6103.     move.l    PlayerBase,a0    ;source
  6104.     move.l    PlayerCOLLBase,a1    ;dest
  6105.     
  6106.     ;320 or next 320 or next 320 or next 320 or next 320 = COLL
  6107.  
  6108.  
  6109.     move.l    #48-1,d6        ;copy 48 rows or 2 char 
  6110. .loop2    
  6111.     move.l    a0,a2        ;save for later
  6112.     move.l    #20-1,d7    ;copy 1 row
  6113. .loop
  6114.     move.w    (a1),d0
  6115.     or.w    (a2),d0        ;or 1st bitplane
  6116.     or.w    40(a2),d0        ;or 2nd bitplane
  6117.     or.w    80(a2),d0        ;or 3rd bitplane
  6118.     or.w    120(a2),d0        ;or 4th bitplane
  6119.     or.w    160(a2),d0        ;or 5th bitplane
  6120.     move.w    d0,(a1)
  6121.     add.l    #2,a2
  6122.     add.l    #2,a1    
  6123.     dbra    d7,.loop
  6124.     add.l    #40*5,a0        ;next row please
  6125.     dbra    d6,.loop2
  6126.  
  6127.     rts
  6128.  
  6129. ConvertPlayer    ;Load N Convert IFF piccy of baddies
  6130.     lea    FileName,a0    
  6131.     move.l    #IFFL_MODE_READ,d0
  6132.     CALLIFF    OpenIFF
  6133.     move.l    d0,iffhandle
  6134.     
  6135.     lea    bitmap,a0
  6136.     move.l    #$05,d0        ;depth
  6137.     move.l    #320*5,d1        ;width
  6138.     move.l    #48+48,d2        ;height & mask
  6139.     CALLGRAF    InitBitMap
  6140.     
  6141.     ;now copy the pointer into the bitmap structure
  6142.     move.l    #5-1,d7
  6143.     move.l    PlayerBase,a0
  6144.     lea    bitmap,a1
  6145. .back    move.l    a0,bm_Planes(a1)
  6146.     add.l    #40,a0
  6147.     add.l    #4,a1    ;next long please
  6148.     dbra    d7,.back
  6149.  
  6150.     move.l    iffhandle,a1
  6151.     lea    bitmap,a0
  6152.     CALLIFF    DecodePic
  6153.     
  6154.     move.l    iffhandle,a1
  6155.     CALLIFF    CloseIFF    
  6156.     
  6157.     
  6158.     rts
  6159.  
  6160. ConvertBulletColl
  6161.     move.l    BulletBase,a0    ;source
  6162.     move.l    BulletCOLLBase,a1    ;dest
  6163.     
  6164.     ;320 or next 320 or next 320 or next 320 or next 320 = COLL
  6165.  
  6166.  
  6167.     move.l    #16-1,d6        ;copy 16 rows or 1 char
  6168. .loop2    
  6169.     move.l    a0,a2        ;save for later
  6170.     move.l    #20-1,d7    ;copy 1 row
  6171. .loop
  6172.     move.w    (a1),d0
  6173.     or.w    (a2),d0        ;or 1st bitplane
  6174.     or.w    40(a2),d0        ;or 2nd bitplane
  6175.     or.w    80(a2),d0        ;or 3rd bitplane
  6176.     or.w    120(a2),d0        ;or 4th bitplane
  6177.     or.w    160(a2),d0        ;or 5th bitplane
  6178.     move.w    d0,(a1)
  6179.     add.l    #2,a2
  6180.     add.l    #2,a1    
  6181.     dbra    d7,.loop
  6182.     add.l    #40*5,a0        ;next row please
  6183.     dbra    d6,.loop2
  6184.  
  6185.     rts
  6186.  
  6187. ConvertBullet    ;Load N Convert IFF piccy of baddies
  6188.     lea    FileName,a0    
  6189.     move.l    #IFFL_MODE_READ,d0
  6190.     CALLIFF    OpenIFF
  6191.     move.l    d0,iffhandle
  6192.     
  6193.     lea    bitmap,a0
  6194.     move.l    #$05,d0        ;depth
  6195.     move.l    #320*5,d1        ;width
  6196.     move.l    #32*(bullgfxline),d2        ;height & mask
  6197.     CALLGRAF    InitBitMap
  6198.     
  6199.     ;now copy the pointer into the bitmap structure
  6200.     move.l    #5-1,d7
  6201.     move.l    BulletBase,a0
  6202.     lea    bitmap,a1
  6203. .back    move.l    a0,bm_Planes(a1)
  6204.     add.l    #40,a0
  6205.     add.l    #4,a1    ;next long please
  6206.     dbra    d7,.back
  6207.  
  6208.     move.l    iffhandle,a1
  6209.     lea    bitmap,a0
  6210.     CALLIFF    DecodePic
  6211.     
  6212.     move.l    iffhandle,a1
  6213.     CALLIFF    CloseIFF    
  6214.     
  6215.     
  6216.     rts
  6217.  
  6218. LoadPlayer1
  6219.     lea    player1ascii,a0
  6220.     bsr    FindAscii    
  6221.     bsr    getfname
  6222.  
  6223.     ;allocate some memory for the picture
  6224.     clr.l    d0        ;allocate some memory for it!
  6225.     move.l    Player1Size,d0
  6226.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  6227.     CALLEXEC    AllocMem
  6228.     move.l    d0,Player1Base
  6229.  
  6230.     move.l    Player1Size,PlayerSize
  6231.     move.l    Player1Base,PlayerBase
  6232.  
  6233.     bsr    ConvertPlayer
  6234.     
  6235.     ;Convert the collision plane, so jump to it
  6236.  
  6237.     ;allocate some memory for the collision plane
  6238.     clr.l    d0        ;allocate some memory for it!
  6239.     move.l    Player1COLLSize,d0
  6240.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  6241.     CALLEXEC    AllocMem
  6242.     move.l    d0,Player1COLLBase
  6243.  
  6244.     move.l    Player1COLLSize,PlayerCOLLSize
  6245.     move.l    Player1COLLBase,PlayerCOLLBase
  6246.     
  6247.     bsr    ConvertPlayerColl
  6248.         
  6249.     rts
  6250.  
  6251. LoadBullet1
  6252.     lea    bullet1ascii,a0
  6253.     bsr    FindAscii    
  6254.     bsr    getfname
  6255.  
  6256.     ;allocate some memory for the picture
  6257.     clr.l    d0        ;allocate some memory for it!
  6258.     move.l    Bullet1Size,d0
  6259.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  6260.     CALLEXEC    AllocMem
  6261.     move.l    d0,Bullet1Base
  6262.  
  6263.     move.l    Bullet1Size,BulletSize
  6264.     move.l    Bullet1Base,BulletBase
  6265.  
  6266.     bsr    ConvertBullet
  6267.     
  6268.     ;Convert the collision plane, so jump to it
  6269.  
  6270.     ;allocate some memory for the collision plane
  6271.     clr.l    d0        ;allocate some memory for it!
  6272.     move.l    Bullet1COLLSize,d0
  6273.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  6274.     CALLEXEC    AllocMem
  6275.     move.l    d0,Bullet1COLLBase
  6276.  
  6277.     move.l    Bullet1COLLSize,BulletCOLLSize
  6278.     move.l    Bullet1COLLBase,BulletCOLLBase
  6279.     
  6280.     bsr    ConvertBulletColl
  6281.         
  6282.     rts
  6283.  
  6284.  
  6285. numtoasc    ;gimme number (d0) and dest ascii (a0)    
  6286.     clr.l    d1
  6287. .howmany100
  6288.     add.l    #1,d1
  6289.     sub.l    #100,d0
  6290.     bge    .howmany100
  6291.     add.l    #100,d0
  6292.     add.b    #"0"-1,d1
  6293.     move.b    d1,(a0)+
  6294.  
  6295.     clr.l    d1
  6296. .howmany10
  6297.     add.l    #1,d1
  6298.     sub.l    #10,d0
  6299.     bge    .howmany10
  6300.     add.l    #10,d0
  6301.     add.b    #"0"-1,d1
  6302.     move.b    d1,(a0)+
  6303.     
  6304.     add.b    #"0",d0
  6305.     move.b    d0,(a0)+
  6306.     
  6307.     rts
  6308.  
  6309. asciinum    dc.b    "000",0
  6310.     even
  6311.     cnop    0,4
  6312.  
  6313. getfname    
  6314.     lea    FileName,a1
  6315. .copyname    cmp.b    #$0a,(a0)
  6316.     beq    .eoname
  6317.     move.b    (a0)+,(a1)+
  6318.     bra    .copyname
  6319. .eoname    move.b    #$00,(a1)+    ;zero termiante
  6320.     rts
  6321.  
  6322. LoadChipData
  6323.     move.l    #FileName,d1    ;filename
  6324.     move.l    #MODE_OLDFILE,d2    ;mode read
  6325.     CALLDOS    Open
  6326.     move.l    d0,Handle
  6327.     
  6328.     move.l    #FileName,d1    ;filename
  6329.     move.l    #ACCESS_READ,d2
  6330.     CALLDOS    Lock
  6331.     move.l    d0,LockFile
  6332.     
  6333.     move.l    LockFile,d1
  6334.     move.l    #FileInfo,d2
  6335.     CALLDOS    Examine
  6336.     
  6337.     lea    FileInfo,a0
  6338.     move.l    fib_Size(a0),FileSize    ;get size please
  6339.  
  6340.     clr.l    d0        ;allocate some memory for it!
  6341.     move.l    FileSize,d0
  6342.     move.l    #MEMF_CLEAR|MEMF_CHIP,d1
  6343.     CALLEXEC    AllocMem
  6344.     move.l    d0,FileBase
  6345.  
  6346.     move.l    Handle,d1        ;filename
  6347.     move.l    FileBase,d2        ;pos in mem
  6348.     move.l    FileSize,d3        ;size
  6349.     CALLDOS    Read
  6350.  
  6351.     move.l    LockFile,d1
  6352.     CALLDOS    UnLock
  6353.  
  6354.     move.l    Handle,d1    ;filename
  6355.     CALLDOS    Close
  6356.     rts
  6357. LoadNormData
  6358.     move.l    #FileName,d1    ;filename
  6359.     move.l    #MODE_OLDFILE,d2    ;mode read
  6360.     CALLDOS    Open
  6361.     move.l    d0,Handle
  6362.     
  6363.     move.l    #FileName,d1    ;filename
  6364.     move.l    #ACCESS_READ,d2
  6365.     CALLDOS    Lock
  6366.     move.l    d0,LockFile
  6367.     
  6368.     move.l    LockFile,d1
  6369.     move.l    #FileInfo,d2
  6370.     CALLDOS    Examine
  6371.     
  6372.     lea    FileInfo,a0
  6373.     move.l    fib_Size(a0),FileSize    ;get size please
  6374.  
  6375.     clr.l    d0        ;allocate some memory for it!
  6376.     move.l    FileSize,d0
  6377.     move.l    #MEMF_CLEAR,d1
  6378.     CALLEXEC    AllocMem
  6379.     move.l    d0,FileBase
  6380.  
  6381.     move.l    Handle,d1        ;filename
  6382.     move.l    FileBase,d2        ;pos in mem
  6383.     move.l    FileSize,d3        ;size
  6384.     CALLDOS    Read
  6385.  
  6386.     move.l    LockFile,d1
  6387.     CALLDOS    UnLock
  6388.  
  6389.     move.l    Handle,d1    ;filename
  6390.     CALLDOS    Close
  6391.     rts
  6392.  
  6393.  
  6394. FindAscii    ;a0 has pointer to line we are looking for
  6395.     move.l    IntBase,a1
  6396.     move.l    a1,a3    ;In HERE
  6397.     move.l    a0,a2    ;Find ME
  6398.     
  6399. .loop
  6400.     cmp.b    #'=',(a2)
  6401.     beq    .Gottim
  6402.     cmp.b    (a2)+,(a3)+    ;are they the same?
  6403.     beq    .loop
  6404.     ;no they are not the same. skip line please
  6405. .skip    cmp.b    #$0a,(a3)+
  6406.     bne    .skip
  6407.     move.l    a0,a2    ;Find ME
  6408.     bra    .loop
  6409.     
  6410. .Gottim
  6411.     add.l    #1,a3    ;skip the =
  6412.     move.l    a3,a0    ;a0 has pointer to name!
  6413.     rts
  6414.     
  6415. LoadIntSet
  6416.     move.l    #IntFName,d1    ;filename
  6417.     move.l    #MODE_OLDFILE,d2    ;mode read
  6418.     CALLDOS    Open
  6419.     move.l    d0,Handle
  6420.     
  6421.     move.l    #IntFName,d1    ;filename
  6422.     move.l    #ACCESS_READ,d2
  6423.     CALLDOS    Lock
  6424.     move.l    d0,LockFile
  6425.     
  6426.     move.l    LockFile,d1
  6427.     move.l    #FileInfo,d2
  6428.     CALLDOS    Examine
  6429.     
  6430.     lea    FileInfo,a0
  6431.     move.l    fib_Size(a0),IntSize    ;get size please
  6432.  
  6433.     clr.l    d0        ;allocate some memory for it!
  6434.     move.l    IntSize,d0
  6435.     move.l    #MEMF_CLEAR,d1
  6436.     CALLEXEC    AllocMem
  6437.     move.l    d0,IntBase
  6438.  
  6439.     move.l    Handle,d1        ;filename
  6440.     move.l    IntBase,d2        ;pos in mem
  6441.     move.l    IntSize,d3        ;size
  6442.     CALLDOS    Read
  6443.  
  6444.     move.l    LockFile,d1
  6445.     CALLDOS    UnLock
  6446.     
  6447.     move.l    Handle,d1    ;filename
  6448.     CALLDOS    Close
  6449.     rts
  6450.  
  6451.     rts
  6452.     even
  6453.     cnop    0,4
  6454. Handle    dc.l    0
  6455. LockFile    dc.l    0
  6456. FileBase    dc.l    0
  6457. FileSize    dc.l    0
  6458. IntBase    dc.l    0
  6459. IntSize    dc.l    0
  6460. FileInfo    dcb.b    240,0
  6461. scratch    dcb.b    20,0    ;for creating things like level002 etc..
  6462. IntFName    dc.b    "YOB:IntSet",0
  6463. charascii    dc.b    "CHAR=",0
  6464. cmapascii    dc.b    "COLMAP=",0
  6465. levascii    dc.b    "LEVEL=",0    ;cat num (scratch)
  6466. backascii    dc.b    "BACK=",0    ;cat num
  6467. baddyascii    dc.b    "BADDY=",0    ;cat num
  6468. titascii    dc.b    "TITLE=",0
  6469. fontascii    dc.b    "FONT=",0
  6470. player1ascii    dc.b    "PLAYER1=",0
  6471. bullet1ascii    dc.b    "BULLET1=",0
  6472. lev1ascii    dc.b    "LEVEL 001",0    ;1st level
  6473. bad1ascii    dc.b    "BADDY01",0        ;1st baddy
  6474. badascii    dc.b    "BADDY",0,0,0    ;1st baddy play with
  6475. FileName    dcb.b    256,0
  6476.     even
  6477.     cnop    0,4
  6478. init_yobtitle
  6479.     lea    sinepos,a2
  6480.     lea    maxline,a3
  6481.     lea    scrline,a4
  6482.     lea    gfkline,a5
  6483.  
  6484.     move.l    #yobtitnum,d2    ;sine pos value
  6485.     move.l    #100,d3        ;max screen line
  6486.     move.l    #0,d4        ;screen line
  6487.     move.l    #0,d5    ;gfk num
  6488.     
  6489.     move.l    #yobtitnum-1,d7
  6490. .loop
  6491.     move.b    d2,(a2)+        ;sine
  6492.     sub.b    #1,d2
  6493.     
  6494.     move.b    d3,(a3)+        ;max line
  6495.     sub.b    #4,d3
  6496.     
  6497.     move.b    d4,(a4)+        ;scr line
  6498.     sub.b    #4,d4
  6499.     
  6500.     move.b    d5,(a5)+
  6501.     add.b    #1,d5        ;gfk line!
  6502.     
  6503.     dbra    d7,.loop
  6504.     
  6505.     rts
  6506. go_yobtitle
  6507.  
  6508.     clr.l    d6        ;cline data
  6509.     lea    yobclistnd-48,a1    ;end of clist!
  6510.     lea    sinepos,a2
  6511.     lea    maxline,a3
  6512.     lea    scrline,a4
  6513.     lea    gfkline,a5
  6514.     
  6515.     move.l    #$2309fffe,clinedummy
  6516.     
  6517.     clr.l    d7
  6518. .main
  6519.     cmp.b    #0,(a4,d7)
  6520.     bge    .overff
  6521.     
  6522.     ;its a bar not on the screen, so fill it with crap!
  6523.     move.l    clinedummy,(a1)        ;copper line!
  6524.     sub.l    #$01000000,clinedummy
  6525.     move.w    #$0200,6(a1)
  6526.     add.l    #48,a1
  6527.     
  6528.     add.b    #1,(a4,d7)        ;next screen line nearly!
  6529.     bra    .next
  6530. .overff
  6531.  
  6532.     ;its a valid screen line!
  6533.     move.l    #$2409fffe,d6        ;starting copper line
  6534.     clr.l    d0
  6535.     move.b    (a2,d7),d0        ;get sine pos
  6536.     lea    play_walk,a6
  6537.     move.b    (a6,d0),d0        ;got sine val
  6538.     add.b    (a4,d7),d0        ;got screen pos
  6539.     
  6540.     cmp.b    (a3,d7),d0        ;is it more than max?
  6541.     blt    .lessmax
  6542.     ;morethan max
  6543.     move.b    (a3,d7),d0        ;make it max then!
  6544. .lessmax
  6545.     move.b    d0,(a4,d7)        ;store new screen pos!
  6546.     
  6547.     bsr    doline
  6548.     
  6549.     ;inc sinepos
  6550.     
  6551.     add.b    #1,(a2,d7)
  6552.     cmp.b    #128,(a2,d7)
  6553.     bne    .notmax
  6554.     move.b    #127,(a2,d7)
  6555. .notmax
  6556.     
  6557.  
  6558. .next    
  6559.     sub.l    #2*48,a1        ;go up a copper line!
  6560.     add.b    #1,d7
  6561.     cmp.b    #yobtitnum,d7
  6562.     bne    .main
  6563.     
  6564. FRIG    ;put a blamk line in..
  6565.     ;get the very bottom copper line..
  6566.     ;add 4 if under $92 then set it to blank!
  6567.     
  6568.     lea    yobclr,a0        ;yob clr
  6569.     lea    yobclistnd-48,a1    ;end of clist!
  6570.     move.l    (a1),d0
  6571.     add.l    #$04000000,d0
  6572.     cmp.l    #$9209fffe,d0
  6573.     bge    .ok
  6574.     move.l    #$9209fffe,d0    ;make it bottom
  6575. .ok
  6576.     move.l    d0,(a0)        ;store it
  6577.     
  6578.     rts
  6579.     
  6580. doline
  6581.     cmp.b    #0,d0
  6582.     beq    .gotline
  6583.     add.l    #$01000000,d6    ;next line
  6584.     sub.b    #1,d0
  6585.     bra    doline
  6586. .gotline
  6587.     ;got the copper line
  6588.     move.l    #screen1,d0        ;gfk start
  6589.     add.l    #104*(5*scrwid),d0
  6590.     add.l    #40,d0 
  6591.     add.l    #36,d0 
  6592.  
  6593.     clr.l    d1
  6594.     move.b    (a5,d7),d1
  6595. .dogfk
  6596.     cmp.b    #0,d1
  6597.     beq    .gotgfk
  6598.     sub.l    #4*(5*scrwid),d0
  6599.     sub.b    #1,d1
  6600.     bra    .dogfk
  6601. .gotgfk
  6602.  
  6603.     ;now bung it in the copper!
  6604.     
  6605.     move.l    d6,(a1)+        ;this line!
  6606.  
  6607.     add.l    #2,a1        ;next line!    
  6608.     move.w    #$5200,(a1)+
  6609.     
  6610.     move.l    d0,d2
  6611.     add.l    #2,a1
  6612.     swap    d0
  6613.     move.w    d0,(a1)+
  6614.     add.l    #2,a1
  6615.     swap    d0
  6616.     move.w    d0,(a1)+
  6617.     
  6618.     add.l    #scrwid,d0
  6619.     add.l    #2,a1
  6620.     swap    d0
  6621.     move.w    d0,(a1)+
  6622.     add.l    #2,a1
  6623.     swap    d0
  6624.     move.w    d0,(a1)+
  6625.  
  6626.     add.l    #scrwid,d0
  6627.     add.l    #2,a1
  6628.     swap    d0
  6629.     move.w    d0,(a1)+
  6630.     add.l    #2,a1
  6631.     swap    d0
  6632.     move.w    d0,(a1)+
  6633.  
  6634.     add.l    #scrwid,d0
  6635.     add.l    #2,a1
  6636.     swap    d0
  6637.     move.w    d0,(a1)+
  6638.     add.l    #2,a1
  6639.     swap    d0
  6640.     move.w    d0,(a1)+
  6641.  
  6642.     add.l    #scrwid,d0
  6643.     add.l    #2,a1
  6644.     swap    d0
  6645.     move.w    d0,(a1)+
  6646.     add.l    #2,a1
  6647.     swap    d0
  6648.     move.w    d0,(a1)+
  6649.     
  6650.  
  6651.     rts
  6652.  
  6653. title_code
  6654.     cmp.b    #0,TitleONFT
  6655.     bne    .notfirst
  6656.     move.w    #$0200,bitplanes    ;planes OFF
  6657.     move.w    #$0200,bitplanes2    ;planes OFF (title)
  6658.  
  6659.     ifeq debugging
  6660.     bsr    vblank
  6661.     bsr    vblank
  6662.     move.l    #new2,$dff080
  6663.     endc
  6664.     
  6665.     move.l    screen1,scrbase
  6666.     bsr    init_bitplanes2
  6667.     bsr    init_yobtitle
  6668.     bsr    nabscreens
  6669.     bsr    copyin_title
  6670.     bsr    titletextprg
  6671.     
  6672.     move.w    #$300,coloursTIT
  6673.     lea    coloursTIT,a0
  6674.     lea    colour2+2,a1
  6675.     bsr    go_colour2        ;part of go_colour
  6676.  
  6677.     move.w    #$5200,bitplanes    ;planes ON
  6678.     move.w    #$5200,bitplanes2    ;planes ON (title)
  6679.     move.b    #1,TitleONFT
  6680.     
  6681. .notfirst
  6682. .main    
  6683.     ;loop round until fire pressed
  6684.     ;bne    .main
  6685.     
  6686.     ;on exit, reset titleonft
  6687.     ;and clear TitleON
  6688.     
  6689.     bsr    go_yobtitle
  6690.     bsr    go_pfts
  6691.     
  6692.     ;now check for fire button
  6693.     btst    #7,$bfe001        ;PRA (6 for the other port)
  6694.     beq    .wait
  6695.     
  6696.     rts
  6697.  
  6698.     ;now wait for him to release the button..
  6699. .wait
  6700. ;    move.w    $dff006,d0
  6701. ;    and.l    #$fff,d0
  6702. ;    move.w    d0,$dff180
  6703.     btst    #7,$bfe001
  6704.     beq    .wait
  6705.  
  6706.     move.b    #0,TitleON
  6707.     move.b    #0,TitleONFT
  6708.     
  6709.     bsr    resscreens
  6710.  
  6711.     bsr    SetupALL    
  6712.     bsr    go_colour        ;restore colour pallete
  6713.  
  6714.     ifeq debugging
  6715.     bsr    vblank
  6716.     bsr    vblank
  6717.     move.l    #new,$dff080
  6718.     endc
  6719.     
  6720.     rts
  6721.     
  6722. nabscreens
  6723.     ;alloc some (fast?) memory to copy the backdrop into
  6724.     move.l    #MEMF_CLEAR,d1    ;Mem Requirements
  6725.     move.l    Bullet1Size,d0    ;Mem size
  6726.     CALLEXEC    AllocMem
  6727.     move.l    d0,Bullet1BaseCP
  6728.     
  6729.     ;now copy screen1 data into screen1copy data
  6730.     move.l    Bullet1Base,a0
  6731.     move.l    Bullet1BaseCP,a1
  6732.     move.l    Bullet1Size,d7
  6733. .copyscr1    move.b    (a0),(a1)+
  6734.     move.b    #0,(a0)+
  6735.     sub.l    #1,d7
  6736.     cmp.l    #0,d7
  6737.     bne    .copyscr1
  6738.  
  6739.     move.l    scrbase,scrbaseCOPY    
  6740.  
  6741.     ;clear out screen1 and screen2
  6742.     move.l    screen1,a0
  6743.     move.l    screen2,a1
  6744.     move.l    #(screensize)-1,d7
  6745. .cls
  6746.     move.b    #0,(a0)+
  6747.     move.b    #0,(a1)+
  6748.     sub.l    #1,d7
  6749.     cmp.l    #0,d7
  6750.     bne    .cls
  6751.     
  6752.     rts
  6753.  
  6754. resscreens
  6755.  
  6756.  
  6757.     ;now copy screen1copy data into screen1 data
  6758.     move.l    Bullet1BaseCP,a0
  6759.     move.l    Bullet1Base,a1
  6760.     move.l    Bullet1Size,d7
  6761. .copyscr1    move.b    (a0)+,(a1)+
  6762.     sub.l    #1,d7
  6763.     cmp.l    #0,d7
  6764.     bne    .copyscr1
  6765.  
  6766.     move.l    scrbaseCOPY,scrbase
  6767.  
  6768.     move.l    Bullet1Size,d0
  6769.     move.l    Bullet1BaseCP,a1
  6770.     CALLEXEC    FreeMem
  6771.     
  6772.     rts
  6773. copyin_title
  6774.     move.l    TitleBase,a0
  6775.     move.l    screen1,a1
  6776.     move.l    screen2,a2
  6777. ;    add.l    #(16*scrwid*5),a1    ;REMOVE IF DOING SILLY COPPER
  6778. ;    add.l    #(16*scrwid*5),a2
  6779.     add.l    #2,a1
  6780.     add.l    #2,a2
  6781.     move.l    #104-1,d6    ;no. lines
  6782. .loop2
  6783.     move.l    #5-1,d5    ;no. bitplanes
  6784. .loop3
  6785.     move.l    #40-1,d7    ;no. bytes across
  6786. .loop
  6787.     move.b    (a0),(a1)+
  6788.     move.b    (a0)+,(a2)+
  6789.     dbra    d7,.loop
  6790.     add.l    #scrwid-40,a1    ;get to next plpace on screen
  6791.     add.l    #scrwid-40,a2    ;get to next plpace on screen
  6792.     dbra    d5,.loop3
  6793.     
  6794.     dbra    d6,.loop2
  6795.     rts
  6796.  
  6797. copycolour
  6798.     lea    colours,a0
  6799.     lea    coloursTIT,a1
  6800.     move.l    #32-1,d7
  6801. .loop
  6802.     move.w    (a0)+,(a1)+
  6803.     dbra    d7,.loop
  6804.     rts
  6805.     
  6806. titletextprg
  6807.  
  6808.     lea    titletext,a6    ;the text
  6809.     
  6810.     move.l    screen1,a1        ;copy into here
  6811.     move.l    screen2,a2        ;copy into here
  6812.     
  6813.     add.l    #(104*5*scrwid)+2,a1
  6814.     add.l    #(104*5*scrwid)+2,a2
  6815.     
  6816.     move.l    a1,spare
  6817.     move.l    a2,spare+4
  6818.     
  6819. .loop
  6820.     cmp.b    #0,(a6)
  6821.     beq    .out
  6822.     clr.l    d0
  6823.     move.b    (a6)+,d0
  6824.     
  6825.     cmp.b    #" ",d0
  6826.     bne    .nospc
  6827.     add.l    #2,a1
  6828.     add.l    #2,a2
  6829.     bra    .loop
  6830. .nospc
  6831.     
  6832.     cmp.b    #$0a,d0    ;return
  6833.     bne    .noret
  6834.     add.l    #48*5*scrwid,spare
  6835.     add.l    #48*5*scrwid,spare+4
  6836.     move.l    spare,a1
  6837.     move.l    spare+4,a2
  6838.     bra    .loop
  6839.     
  6840. .noret
  6841.     
  6842.     
  6843.     move.l    FontBase,a0
  6844.     sub.b    #"a"+0,d0
  6845.     rol.l    #2,d0
  6846.     add.l    d0,a0
  6847.  
  6848.     PUSHALL
  6849.     bsr    printtext
  6850.     PULLALL
  6851.  
  6852. .nextspc    
  6853.     add.l    #4,a1        ;next place
  6854.     add.l    #4,a2        ;next place
  6855.     
  6856.     bra    .loop
  6857.  
  6858. .out    rts
  6859.     
  6860. printtext
  6861.     ;a0 has gfk. a1 has dest.....
  6862.     ;a0 832/8 wide
  6863.     ;a1 scrwid wide
  6864.     ;a2 scrwid wide
  6865.     
  6866.     
  6867.     clr.l    d6
  6868.     move.w    #48-1,d6        ;no. lines
  6869. .lines    
  6870.     move.l    a0,a3
  6871.     move.l    a1,a4
  6872.     move.l    a2,a5
  6873.  
  6874.     clr.l    d7
  6875.     move.w    #5-1,d7        ;no. bitplanes
  6876. .bitplanes
  6877.     move.w    (a3),(a4)        ;1 word
  6878.     move.w    2(a3),2(a4)        ;2 word
  6879.     move.w    (a3),(a5)        ;1 word
  6880.     move.w    2(a3),2(a5)        ;2 word
  6881.  
  6882.     add.l    #scrwid,a4        ;next bplane
  6883.     add.l    #scrwid,a5        ;next bplane
  6884.     add.l    #104,a3        ;next bplane
  6885.     dbra    d7,.bitplanes
  6886.  
  6887.     add.l    #104*5,a0
  6888.     add.l    #scrwid*5,a1
  6889.     add.l    #scrwid*5,a2
  6890.  
  6891.     dbra    d6,.lines
  6892.     
  6893.     rts
  6894.     
  6895. NewLevel
  6896. ;    move.w    $dff006,d0
  6897. ;    and.l    #$fff,d0
  6898. ;    move.w    d0,$dff180
  6899.     
  6900.     add.b    #1,LevelNum
  6901.     cmp.b    #10,LevelNum
  6902.     beq    .fuck        ;load new set
  6903.     bsr    init_bulls
  6904.     bsr    dolevnum
  6905.     lea    scratch,a2        ;look for this level!
  6906.     bsr    FindLev
  6907.     bsr    SetupALL
  6908.     
  6909. .fuck
  6910.     rts
  6911.     
  6912. init_bulls
  6913.     ;baddy bullets
  6914.     lea    bullet_list,a2
  6915.     move.l    #bullet_max-1,d7
  6916.     
  6917. .loop    move.b    #DEAD,bull_status(a2)
  6918.     add.l    #bullet_nd-bullet,a2    ;next bullet
  6919.     dbra    d7,.loop
  6920.  
  6921.     lea    gun_list,a2
  6922.     move.l    #gun_max-1,d7
  6923. .loop2
  6924.     move.b    #DEAD,bull_status(a2)
  6925.     add.l    #bullet_nd-bullet,a2    ;next bullet
  6926.     dbra    d7,.loop2
  6927.  
  6928.  
  6929.     rts
  6930.     
  6931. dolevnum
  6932.     ;copy level to scratch so we can add the number to it
  6933.     lea    lev1ascii,a0
  6934.     lea    scratch,a1
  6935. .copy    move.b    (a0)+,(a1)+
  6936.     bne    .copy
  6937.  
  6938.     ;now go back a further 3 to get to the start of the no.
  6939.     ;LEVEL 001
  6940.     ;      ^
  6941.     sub.l    #4,a1
  6942.         
  6943.     clr.l    d0
  6944.     move.b    LevelNum,d0
  6945.     move.l    a1,a0
  6946.     bsr    numtoasc
  6947.  
  6948.     rts
  6949.     
  6950. go_flash
  6951.     cmp.w    #0,flash
  6952.     beq    .out
  6953.     sub.w    #$111,flash
  6954.     
  6955. .out    rts
  6956.     
  6957.     even
  6958.     cnop    0,4
  6959.  
  6960. new:
  6961.     dc.w    $009c,$8010
  6962.     dc.w    bpl1mod
  6963. modeven    dc.w    (scrwid*5)-40
  6964.     dc.w    bpl2mod
  6965. mododd    dc.w    (scrwid*5)-40
  6966.     dc.w    dmacon,$0020
  6967. scnposs    dc.w    diwstrt,$2c81
  6968. scnpose    dc.w    diwstop,$2cc1 
  6969.     dc.w    ddfstrt,$38
  6970.     dc.w    ddfstop,$d0
  6971.     dc.w    bplcon0
  6972. bitplanes    dc.w    $5200
  6973.     dc.w    bplcon1,$0
  6974.     dc.w    bplcon2,0
  6975.     dc.w    bplcon3,$0c00    ;bplcon3
  6976.     dc.w    bpl1h
  6977. bit1h    dc.w    0
  6978.     dc.w    bpl1l
  6979. bit1l    dc.w    0
  6980.     dc.w    bpl2h
  6981. bit2h    dc.w    0
  6982.     dc.w    bpl2l
  6983. bit2l    dc.w    0
  6984.     dc.w    bpl3h
  6985. bit3h    dc.w    0
  6986.     dc.w    bpl3l
  6987. bit3l    dc.w    0
  6988.     dc.w    bpl4h
  6989. bit4h    dc.w    0
  6990.     dc.w    bpl4l
  6991. bit4l    dc.w    0
  6992.     dc.w    bpl5h
  6993. bit5h    dc.w    0
  6994.     dc.w    bpl5l
  6995. bit5l    dc.w    0
  6996.  
  6997. colour    include    slyma/colclist
  6998.     dc.w    $0180
  6999. flash    dc.w    $0000
  7000.  
  7001.     dc.l    $8009fffe    
  7002.     dc.l    $ffdffffe
  7003.     dc.w    $2c09,$fffe,bplcon0,$0200
  7004.     
  7005.     dc.w    $ffff,$fffe        ;end of coper list
  7006.  
  7007.     dc.l    0
  7008. new2:
  7009.     dc.w    $009c,$8010
  7010.     
  7011. ;    dc.l    $2989fffe
  7012. ;    dc.w    bplcon0,$0200    
  7013. ;    dc.l    $2c09fffe
  7014. ;    dc.w    bplcon0,$5200    
  7015.  
  7016. yobclist    dcb.b    yobtitnum*(4+4+(8*5)),0    ;the big title in chunks of 4
  7017. yobclistnd
  7018. yobclr    dc.l    $9209fffe        ;put a blank line after the bottom YOBtit line
  7019.     dc.w    bplcon0,$0200    
  7020.     
  7021.     dc.l    $9309fffe
  7022.     dc.l    $0180000f
  7023.     dc.l    $9409fffe
  7024.     dc.l    $01800000
  7025.     dc.w    bplcon0,$0200    
  7026. colour2    include    slyma/colclist
  7027.  
  7028.     dc.l    $fe09fffe
  7029.     dc.l    $0180000f
  7030.     dc.l    $ff09fffe
  7031.     dc.l    $01800400
  7032.     dc.w    bplcon0,$5200    
  7033.     dc.l    $ffdffffe
  7034.     ;okay, we want 40 lines of 5bitplane data for the press fire to start
  7035.     
  7036. pfts    dcb.b    40*(4+(8*5)),0        ;40 lines cline+(bpl1h,0,bpl1l,0)*5
  7037.  
  7038.     dc.w    bpl1mod
  7039. modeven2    dc.w    (scrwid*5)-40
  7040.     dc.w    bpl2mod
  7041. mododd2    dc.w    (scrwid*5)-40
  7042.     dc.w    dmacon,$0020
  7043. scnposs2    dc.w    diwstrt,$2c81
  7044. scnpose2    dc.w    diwstop,$2cc1 
  7045.     dc.w    ddfstrt,$38
  7046.     dc.w    ddfstop,$d0
  7047.  
  7048.     dc.w    bplcon0
  7049. bitplanes2    dc.w    $5200
  7050.     dc.w    bplcon1,$0
  7051.     dc.w    bplcon2,0
  7052.     dc.w    bplcon3,$0c00    ;bplcon3
  7053.  
  7054.     dc.w    $ffff,$fffe        ;end of coper list
  7055.  
  7056.     dc.l    0
  7057.  
  7058. old    dc.l    0
  7059.  
  7060. gfxname    dc.b    "graphics.library",0
  7061. dosname    dc.b    "dos.library",0
  7062. iffname    dc.b    "iff.library",0
  7063. intname    dc.b    "intuition.library",0
  7064. wbname          dc.b  "Workbench",0
  7065.     even
  7066. colours    dcb.w    32
  7067. coloursTIT    dcb.w    32
  7068.     even
  7069. _GfxBase    dc.l    0
  7070. _IFFBase    dc.l    0
  7071. _DOSBase    dc.l    0
  7072. _IntuitionBase    dc.l    0
  7073.  
  7074. wbview          dc.l  0
  7075. oldres          dc.l  0
  7076. wbscreen        dc.l  0
  7077.  
  7078. taglist         dc.l  VTAG_SPRITERESN_GET
  7079. resolution      dc.l  SPRITERESN_ECS
  7080.                 dc.l  TAG_DONE,0
  7081.  
  7082.  
  7083.  
  7084. collbase    dc.l    0    ;pointer to collision base!
  7085. scrbase    dc.l    0    ;pointer to screen area!
  7086. scrbaseCOPY    dc.l    0    ;pointer to screen area! copy
  7087. screen1    dc.l    0    ;pointer to screen
  7088. screen2    dc.l    0    ;pointer to screen
  7089. iffhandle    dc.l    0    ;iff handle
  7090. bitmap
  7091.     dcb.b    40
  7092.     even
  7093.     cnop    0,4
  7094.  
  7095. ;********  Memory Allocation Tables *********
  7096. CharBase    dc.l    0
  7097. CharSize    dc.l    0
  7098. MaskBase    dc.l    0
  7099. MaskSize    dc.l    0
  7100. CmapBase    dc.l    0
  7101. CmapSize    dc.l    0
  7102. LevBase    dc.l    0    ;pointer to current level (in ldbase)
  7103. BadBase    dc.l    0    ;pointer to 1st baddy data (in ldbase)
  7104. LDBase    dc.l    0    ;block of 10 levels and baddy data
  7105. LDSize    dc.l    0
  7106. BackBase    dc.l    0
  7107. BackSize    dc.l    50*5*256    ;(FAST)
  7108. BaddySize    dc.l    0    ;Internal baddy size (for convert)
  7109. BaddyBase    dc.l    0    ;Internal baddy base (for convert)
  7110. PlayerSize    dc.l    0    ;Internal player size
  7111. PlayerBase    dc.l    0    ;Internal player base
  7112. PlayerCOLLSize    dc.l    0    ;Internal player size
  7113. PlayerCOLLBase    dc.l    0    ;Internal player base
  7114. BulletSize    dc.l    0    ;Internal bullet size
  7115. BulletBase    dc.l    0    ;Internal bullet base
  7116. BulletCOLLSize    dc.l    0    ;Internal bullet size
  7117. BulletCOLLBase    dc.l    0    ;Internal bullet base
  7118. BaddyCOLLSize    dc.l    0    ;Internal baddy COLL size (for convert)
  7119. BaddyCOLLBase    dc.l    0    ;Internal baddy COLL base (for convert)
  7120. Baddy1Size    dc.l    82*5*(baddygfx*32)
  7121. Baddy1Base    dc.l    0
  7122. Baddy1COLLSize    dc.l    82*1*(baddygfx*16)
  7123. Baddy1COLLBase    dc.l    0
  7124. Player1Size    dc.l    42*5*96    ;48+48 = 96 (player + mask)
  7125. Player1Base    dc.l    0
  7126. Player1COLLSize    dc.l    42*1*48
  7127. Player1COLLBase    dc.l    0
  7128. Bullet1Size    dc.l    42*5*32*bullgfxline    ;16+16 = 32 (bullet + mask)
  7129. Bullet1Base    dc.l    0
  7130. Bullet1BaseCP    dc.l    0
  7131. Bullet1COLLSize    dc.l    42*1*32*bullgfxline
  7132. Bullet1COLLBase    dc.l    0
  7133. TitleSize    dc.l    40*5*110    ;title screen (FAST)
  7134. TitleBase    dc.l    0
  7135. FontSize    dc.l    (832/8)*5*55    ;title screen (FAST) (should be 48 but iff library fucked)
  7136. FontBase    dc.l    0
  7137.             ;these are allocated in alloctemp
  7138. bad_temp1Base    dc.l    0
  7139. bad_temp2Base    dc.l    0
  7140. player_temp1Base    dc.l    0
  7141. player_temp2Base    dc.l    0
  7142. bullet_temp1Base    dc.l    0
  7143. bullet_temp2Base    dc.l    0
  7144. gun_temp1Base    dc.l    0
  7145. gun_temp2Base    dc.l    0
  7146. lazertempBase    dc.l    0
  7147.  
  7148. lazercollxy        dcb.l    bullet_max+1,0
  7149.         ;this stores the lethal X,Y of the lazer beams.
  7150.         ;anything in this area will be destoryed.
  7151.         ;Word X Word Y
  7152.         ;if X & Y = 0 then dead lazer!
  7153.  
  7154.  
  7155. RegSave        dc.l    0
  7156. oldpri        dc.l    0    
  7157.  
  7158.  
  7159. bad_no    dcb.l    bad_max+1,0
  7160. ;* = fixed
  7161. bad_type1    ;dumb l/r
  7162.     dc.l    "DUMB"    ;dats my name! *
  7163.     dc.w    0    ;xpos (pix) *
  7164.     dc.w    0    ;ypos (pix) *
  7165.     dc.l    0    ;actual pos *
  7166.     dc.w    0    ;smooth scroll *
  7167.     dc.b    0    ;anim char * (what pos in list)
  7168.     dc.b    0    ;speed *
  7169.     dc.b    0    ;i can go udlr *
  7170.     dc.b    0    ;i am going r*
  7171.     dc.b    0    ;what is my weapon *
  7172.     dc.b    0    ;whats i hit for *
  7173.     dc.b    0    ;whats my hp *
  7174.     dc.b    0
  7175.     dc.b    0
  7176.     dc.b    0    ;map x *
  7177.     dc.b    0    ;map y *
  7178.     dc.b    7,10,11,12,13,14,15,16,17    ;anim right *
  7179.     dc.b    7,0,1,2,3,4,5,6,7    ;anim left *
  7180.     dc.b    3,0,0,0,0,0,0,0,0    ;anim right jump *
  7181.     dc.b    3,0,0,0,0,0,0,0,0    ;anim left junp *
  7182.     dc.b    0        ;anim offet
  7183.     dc.b    0        ;mario pos
  7184.     dc.b    0
  7185.     dc.b    0        ;doing
  7186.     dc.b    0        ;falling pos
  7187.     dc.b    gravity
  7188.     dc.b    0
  7189.     dc.l    0        ;actual old pos!
  7190.     dc.b    0        ;jumping pos
  7191.     dc.b    0
  7192.     dc.b    0        ;status!
  7193.     dc.b    1        ;bad_gfxnum    (0-256)
  7194.     dc.w    24        ;gun gfk
  7195.     dc.b    0        ;rand2
  7196.     dc.b    0        ;bad_LBnk    lazer restore bank 
  7197.     dc.b    0        ;bad_dedcnt
  7198.     dc.b    0,0,0,0,0,0,0,0,0    ;spacer
  7199.     cnop    0,4
  7200.     
  7201. bad_type1_nd    ;if you add any more * bad structure
  7202.  
  7203. ;bad_cango & go infos
  7204. ;0000     can shoot UDLR
  7205. ;    0000 can i move UDLR
  7206.  
  7207. ;ability these are things he can do
  7208. ;       0 fire (intelligent fire (when i can see summink)
  7209. ;      0  jump
  7210. ;     0   dieing
  7211. ;    0    fall off platforms
  7212. ;   0     fire at will (rnd) 
  7213. ;  0      seek player (either is or isnt)
  7214. ; 0       hide from player  (either is or isnt)
  7215. ;0        platform dude (either is or isnt)
  7216. ;look
  7217. ;0000     look for player UDLR
  7218. ;    0    use power ups
  7219. ;     0   mario stylee walking
  7220.  
  7221. ;doing these are things hes doing
  7222. ;       0 firing (int)
  7223. ;      0  jumping
  7224. ;     0   dieing
  7225. ;    0    falling
  7226. ;   0     firing (rnd)
  7227. ;  0      
  7228. ; 0
  7229. ;0
  7230.  
  7231.     ;bit defs:-
  7232.     ;the no. at the end is the actual bit effected 0-15
  7233.     ;to use:
  7234.     ;    BOBB_UP    3 = %0011  bset   BOBB_UP,d0
  7235.     ;    BOBF_UP    8 = %1000  move.w BOBF_UP,d0
  7236.     
  7237.     BITDEF    BOB,UP,3
  7238.     BITDEF    BOB,DOWN,2
  7239.     BITDEF    BOB,LEFT,1
  7240.     BITDEF    BOB,RIGHT,0
  7241.     BITDEF    BOB,SHOOT,4    ;Player only.......
  7242.     
  7243.     BITDEF    BOB,GUN1,0    ;intelligent fire
  7244.     BITDEF    BOB,JUMP,1
  7245.     BITDEF    BOB,DEAD,2
  7246.     BITDEF    BOB,FALL,3
  7247.     BITDEF    BOB,GUN2,4    ;rand fire
  7248.     BITDEF    BOB,PLAT,7
  7249.     
  7250.     BITDEF    LOOK,MARIO,2
  7251.     
  7252.     BITDEF    ATTR,SEEKX,0    ;seek in x
  7253.     BITDEF    ATTR,SEEKY,1    ;seek in y
  7254.     BITDEF    ATTR,EDGE,2        ;bounces on edge of scr
  7255.     BITDEF    ATTR,BFORM,3    ;bounces off pform
  7256.     BITDEF    ATTR,HFORM,4    ;hugs pform
  7257.     BITDEF    ATTR,AGRAV,5    ;fall to gravity ALWAYS
  7258.     BITDEF    ATTR,GRAV,6        ;fall to gravity when out of energy
  7259.  
  7260.     ;kill bullet when    
  7261.     BITDEF    KBUL,BOTTOM,0    ;bottom of screen
  7262.     BITDEF    KBUL,EDGE,1        ;edges of screen
  7263.     BITDEF    KBUL,PFORM,2    ;platform of screen
  7264.     
  7265.     
  7266.     
  7267.  
  7268. WeapSmart    equ    1    
  7269. WeapNorm    equ    2    ;players
  7270. WeapLazer    equ    3
  7271. WeapBounce    equ    4    ;players
  7272.     
  7273.  
  7274. ;SPARE BITS in look & doing
  7275.  
  7276. ;animation
  7277. ;first byte is how many frames for direction
  7278. ;then follows the frame no.s (upto 8 different frames)
  7279.  
  7280. bad_name    equ    0    ;whats you name
  7281. bad_x    equ    4    ;xpos
  7282. bad_y    equ    6    ;ypos
  7283. bad_actual    equ    8    ;coarse
  7284. bad_smooth    equ    12    ;smooth
  7285. bad_anim    equ    14    ;what char am I?
  7286. bad_speed    equ    15    ;speed
  7287. bad_cango    equ    16    ;what dirs am i alowed
  7288. bad_go    equ    17    ;what dir(s) am i going
  7289. bad_gun    equ    18    ;what is my weapon
  7290. bad_power    equ    19    ;what I hit for
  7291. bad_hp    equ    20    ;what my hit pts
  7292. bad_ability    equ    21    ;what can i do
  7293. bad_look    equ    22    ;what i see
  7294. bad_mapx    equ    23    ;players mapx pos
  7295. bad_mapy    equ    24    ;players mapy pos
  7296. bad_an_rcnt    equ    25    ;how many frames for right
  7297. bad_an_rfrm    equ    26    ;anim frames for right
  7298. bad_an_lcnt    equ    34    ;how many frames for left
  7299. bad_an_lfrm    equ    35    ;anim frames for left
  7300. bad_an_ucnt    equ    43    ;how many frames for up
  7301. bad_an_ufrm    equ    44    ;anim frames for up
  7302. bad_an_dcnt    equ    52    ;how many frames for down
  7303. bad_an_dfrm    equ    53    ;anim frames for down
  7304. bad_an_off    equ    61    ;anim offset to suss dir anims
  7305. bad_mar    equ    62    ;what pos in mario movement pos thing
  7306. bad_mar_max    equ    63    ;what the max pos in mario movement
  7307. bad_doing    equ    64    ;what am i doing
  7308. bad_fal    equ    65    ;falling counter
  7309. bad_fal_max    equ    66    ;falling maximum
  7310. bad_randg    equ    67    ;do summink on this no. GUN
  7311. bad_act_was    equ    68    ;bad actual pos
  7312. bad_jmp_pos    equ    72    ;jumping pos
  7313. bad_platx    equ    73    ;platform pos
  7314. bad_status    equ    74    ;status: alive dead or what!
  7315. bad_gfxnum    equ    75    ;what bank of gfx are we using (0-256)
  7316. bad_gungfk    equ    76    ;baddy gun gfk (R) > < > <
  7317. bad_rand2    equ    77    ;do summink on this no. OTHER
  7318. bad_LBnk    equ    78    ;Lazer restore bank 
  7319. bad_dedcnt    equ    79    ;counter for dead baddy!
  7320. ;bad_an_off how to use it
  7321. ;add the contents to bad_an_rcnt(a1) to get the bank of gfks to use
  7322. ;i.e. bad_an_off = 0 then use right anim
  7323. ;if   bad_an_off = 9 then use left anim
  7324. ;
  7325.     cnop    0,4
  7326. bads_list
  7327.     dcb.b    bad_max*(bad_type1_nd-bad_type1),0
  7328.  
  7329. ;for each new baddy you make, put his name and jmp into the bit below
  7330. bad_nums    dc.l    51,52,53,54,55,56,57,0        ;what lev no. is bad
  7331. ;     Move    Fire
  7332. ;51 =   LR        ;on Pform
  7333. ;52 =  DLR     UDLR     ;Fall off pform <SEEK bullet>
  7334. ;53 = UD          R    ;jumps up n down shoot right
  7335. ;54 = UD      L    ;jumps up n down shoot left
  7336. ;55 =             R    ;Lazer Beam RIGHT
  7337. ;56 =      L    ;Lazer Beam Left
  7338. ;57 = UDLR      LR    ;Seeks Player
  7339.  
  7340. badcheck    dc.l    0    ;check to see how many baddys alive
  7341. badcnt    dc.b    0    ;check baddy alive counter!
  7342. badgone    dc.b    0    ;results of bad counter
  7343.  
  7344. LevelNum    dc.b    0    ;starting level
  7345. switch    dc.b    0    ;which screen
  7346. random    dc.b    0    ;random number thingy!
  7347. randplay    dc.b     0    ;random player to chase thingy! *NOT WRITTEN*
  7348. num_players    dc.b    0    ;how many players
  7349. waitflag    dc.b    0    ;has another direction added to wait
  7350. temp    dc.b    0    ;tempory store for anything
  7351. TitleON    dc.b    0    ;is the title screen on?
  7352. TitleONFT    dc.b    0    ;is the title screen on for the first time?
  7353.     cnop    0,4
  7354.  
  7355. walk_thru
  7356.     dc.b    0    ;what chars he cant walk l/r thru or jump u/d thru
  7357.     dc.b    0
  7358.  
  7359. walk_on    ;be a good idea to make this a between 2-12 routine instead of 123456789101112
  7360.     dc.b    2,3,4,5,6,7,8,9,10,11,12,0    ;what chars we can walk on    
  7361. ;for baddies with mario style walking, this is the table
  7362. bad_jump    dc.b    0,0,0,0
  7363. bad_walk    
  7364.     dc.b    0,1,1,1,1,1,1,1
  7365.     dc.b    2,2,2,2,2,2,2,3
  7366.     dc.b    3,3,3,3,3,4,4,4
  7367.     dc.b    4,4,5,5,5,5,6,6
  7368.     dc.b    6,7,7,8,9,10,11,12
  7369.     dc.b    13,14,15,15,15,15,15,15
  7370.  
  7371.     dc.b    0,0,0,0,0,0,0,0
  7372. play_walk
  7373.     dc.b    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  7374.     dc.b    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  7375.     dc.b    3,3,3,3,3,3,3,3,3,3,3,3,3,3
  7376.     dc.b    4,4,4,4,4,4,4,4,4,4,4,4,4
  7377.     dc.b    5,5,5,5,5,5,5,5,5,5,5,5
  7378.     dc.b    6,6,6,6,6,6,6,6,6,6,6
  7379.     dc.b    7,7,7,7,7,7,7,7,7,7
  7380.     dc.b    8,8,8,8,8,8,8,8,8
  7381.     dc.b    9,9,9,9,9,9,9,9
  7382.     dc.b    10,10,10,10,10,10,10
  7383.     dc.b    11,11,11,11,11,11
  7384.     dc.b    12,12,12,12,12
  7385.     dc.b    13,13,13,13
  7386.     dc.b    14,14,14
  7387.     dc.b    15,15
  7388.     dc.b    16
  7389.  
  7390. bull_table
  7391.     dc.b    0
  7392.     dcb.b    1,-6
  7393.     dcb.b    1,-5
  7394.     dcb.b    1,-4
  7395.     dcb.b    1,-3
  7396.     dcb.b    1,-2
  7397.     dcb.b    1,-1
  7398.     dcb.b    16,1
  7399.     dcb.b    15,2
  7400.     dcb.b    14,3
  7401.     dcb.b    13,4
  7402.     dcb.b    12,5
  7403.     dcb.b    11,6
  7404.     dcb.b    10,7
  7405.     dcb.b    9,8
  7406.     dcb.b    8,9
  7407.     dcb.b    7,10
  7408.     dcb.b    6,11
  7409.     dcb.b    5,12
  7410.     dcb.b    4,13
  7411.     dcb.b    3,14
  7412.     dcb.b    2,15
  7413.     dcb.b    1,16
  7414.  
  7415.  
  7416.     ;    00,01,02,03,04,05,06,07,08,09,10
  7417. gfktab    dc.l    00,00,00,00,00,00,00,00,00,00,00
  7418. liveplayers    dcb.b    players_max+1,0    ;need extra one for ff termiated
  7419.  
  7420.     cnop    0,4    
  7421.  
  7422. player1    ;please define in creatplayer (just defaults here)
  7423.     dc.w    100    ;players x
  7424.     dc.w    100    ;players y
  7425.     dc.l    0    ;players actual (add scrbase for pos)
  7426.     dc.w    0    ;players smooth (add 09f0 to it)
  7427.     dc.b    0    ;input device (i.e. 0-joy0 1-joy1 etc)
  7428.     dc.b    0    ;directions from joystick
  7429.     dc.l    0    ;players old position
  7430.     dc.b    0    ;mapx
  7431.     dc.b    0    ;mapy
  7432.     dc.b    16    ;platx
  7433.     dc.b    0    ;speed
  7434.     dc.b    20    ;speed max    
  7435.     dc.b    1    ;step (step through speed data)
  7436.     dc.b    0    ;going
  7437.     dc.b    8    ;slippery (0 - ultra slippy)
  7438.     dc.b    0    ;skill normal mode
  7439.     dc.b    0    ;doing
  7440.     dc.b    0    ;fall counter
  7441.     dc.b    0    ;fall max
  7442.     dc.b    0    ;status
  7443.     dc.b    0    ;anim style
  7444.     dc.b    0    ;anim frame
  7445.     dc.b    0    ;anim count
  7446.     dc.b    0    ;jump pos
  7447.     dc.b    0    ;cresend of jump
  7448.     dc.b    0    ;player hitpoints
  7449.     dc.b    0    ;player hittime
  7450.     dc.b    0    ;player dedcnt (see bullet) 0/1
  7451.     dc.b    0    ;players gun
  7452.     dc.b    0    ;ammo for gun
  7453.     dc.b    0    ;reload max
  7454.     dc.b    0    ;current reload counter!
  7455.     dc.b    0    ;max no. bullets
  7456.     dc.b    0    ;cuttent no. bullets
  7457.     dc.b    0    ;current gun gfk!
  7458.     dc.b    0    ;gun power
  7459.     cnop    0,4
  7460.     
  7461. player1_nd
  7462. players_list    ;keep right under player1
  7463.     dcb.b    players_max*(player1_nd-player1),0
  7464.  
  7465. play_xpos    equ    0
  7466. play_ypos    equ    2
  7467. play_actual    equ    4
  7468. play_smooth    equ    8
  7469. play_port    equ    10    ;what joy port do i read from ?
  7470. play_do    equ    11    ;please go this way
  7471. play_was    equ    12    ;players old pos.
  7472. play_mapx    equ    16    ;map posx
  7473. play_mapy    equ    17    ;map posy
  7474. play_platx    equ    18    ;platform X
  7475. play_speed    equ    19    ;what place in speed table
  7476. play_spdmax    equ    20    ;max pos in speed table
  7477. play_step    equ    21    ;how fast he goes through table (def 1)
  7478. play_going    equ    22    ;what direction am i actually going
  7479. play_slip    equ    23    ;how slippery is the surface player is on
  7480. play_skill    equ    24    ;what mode am I
  7481. play_doing    equ    25    ;same as baddy!
  7482. play_fal    equ    26    ;falling counter
  7483. play_falmax    equ    27    ;falling maximum
  7484. play_status    equ    28    ;status: alive dead or what!
  7485. play_anim_style    equ    29    ;animation style (see below)
  7486. play_anim_frame    equ    30    ;animation frame
  7487. play_anim_count    equ    31    ;animation counter
  7488. play_jmp_pos    equ    32    ;jumping pos
  7489. play_cres        equ    33    ;hey im in the cresent part of the jump
  7490. play_hp        equ    34
  7491. play_hptime        equ    35    ;how long have i been hit for!
  7492. play_dedcnt        equ    36    ;counter to remove from screen! (same as bullet)
  7493. play_gun        equ    37    ;what gun have i got!
  7494. play_ammo        equ    38    ;how much ammo!
  7495. play_reloadmax    equ    39    ;how long between reloads!
  7496. play_reloadcnt    equ    40    ;current time between reloads!
  7497. play_maxbulls    equ    41    ;maximum no. bullets!
  7498. play_maxbullscnt    equ    42    ;current no. bullets!
  7499. play_gungfk        equ    43    ;player gun gfk
  7500. play_gunpower    equ    44    ;players gun power
  7501. ;play_skill
  7502. ;what is the dude doing????
  7503. ;0 = normal walk/jump/fall
  7504. ;1 = jetpack
  7505. ;2 = swim
  7506.  
  7507. ;Ports (joystick ports etc)
  7508. JOYPORT1    equ    0    ;port 1
  7509. JOYPORT2    equ    1    ;port 2
  7510.  
  7511. ;play_anim_style
  7512. ;0 = walk left
  7513. ;1 = walk right
  7514. ;
  7515. Anim_RIGHT    equ    0
  7516. Anim_LEFT    equ    1
  7517.  
  7518.     cnop    0,4
  7519.     even
  7520. bullet
  7521.     dc.w    0    ;x    
  7522.     dc.w    0    ;y
  7523.     dc.l    0    ;actual
  7524.     dc.l    0    ;was
  7525.     dc.w    0    ;smooth
  7526.     dc.b    0    ;status
  7527.     dc.b    0    ;gun
  7528.     dc.b    0    ;speedx
  7529.     dc.b    0    ;speedy
  7530.     dc.b    0    ;speed maxx
  7531.     dc.b    0    ;speed maxy
  7532.     dc.b    0    ;step through table x
  7533.     dc.b    0    ;step through table y
  7534.     dc.b    0    ;wait before moving
  7535.     dc.b    0    ;going at the mo
  7536.     dc.w    0    ;how long the bullet lives
  7537.     dc.b    0    ;can go if want to
  7538.     dc.b    0    ;dead counter
  7539.     dc.w    0    ;seekx
  7540.     dc.w    0    ;seeky
  7541.     dc.b    0    ;bullet wants to go
  7542.     dc.b    0    ;wait before moving Y
  7543.     dc.b    0    ;what player your after
  7544.     dc.b    0    ;what attributes
  7545.     dc.b    0    ;what kills bullet
  7546.     dc.b    1    ;bullet power (how much i hit for)
  7547.     dc.w    24    ;gfk start offset
  7548.     dc.w    0    ;how long the bullet lives
  7549.     dc.b    0    ;Lazer restore count
  7550.     dc.b    0    ;spare
  7551.     dc.l    0    ;Players address
  7552.     dc.w    0    ;lazerx COLLISION
  7553.     dc.w    0    ;lazerx2 COLLISION
  7554.     dc.w    0    ;lazery COLLISION
  7555.     dc.w    0    ;lazery2 COLLISION
  7556.         ;this stores the lethal X,Y of the lazer beams.
  7557.         ;anything in this area will be destoryed.
  7558.         ;Word X Word Y
  7559.         ;if X & Y = 0 then dead lazer!
  7560.  
  7561.     dc.l    0    ;Lazer restore offset
  7562.     dc.b    0    ;Lazer restore Bank
  7563.     dc.b    0    ;position on mapx (most bullets DONT use it)
  7564.     dc.b    0    ;position on mapy (most bullets DONT use it)
  7565.     
  7566.     cnop    0,4
  7567. bullet_nd
  7568.  
  7569.     
  7570. bull_xpos    equ    0
  7571. bull_ypos    equ    2
  7572. bull_actual    equ    4
  7573. bull_was    equ    8
  7574. bull_smooth    equ    12
  7575. bull_status    equ    14    ;dead/dying/okay/new
  7576. bull_gun    equ    15
  7577. bull_speedx    equ    16
  7578. bull_speedy    equ    17
  7579. bull_maxx    equ    18
  7580. bull_maxy    equ    19
  7581. bull_stepx    equ    20
  7582. bull_stepy    equ    21
  7583. bull_waitx    equ    22    ;waiting for conuter before moving
  7584. bull_go    equ    23    ;where am i going
  7585. bull_life    equ    24    ;how much life
  7586. bull_cango    equ    26    ;can go if want to
  7587. bull_dedcnt    equ    27    ;0/1 clear from both scr switches
  7588. bull_seekx    equ    28    ;try to get here x
  7589. bull_seeky    equ    30    ;try to get here y
  7590. bull_wantgo    equ    32    ;where does he want to go
  7591. bull_waity    equ    33    ;waiting counter for y
  7592. bull_player    equ    34    ;what player are you after!
  7593. bull_attr    equ    35    ;attributes
  7594. bull_death    equ    36    ;what can kill the bullet (player/bullet/sides etc)
  7595. bull_power    equ    37    ;what bullet hits for
  7596. bull_gfk    equ    38    ;what gfk offset bullet is
  7597. bull_life2    equ    40    ;how much life when seeking
  7598. bull_Lcnt    equ    42    ;Lazer restore count
  7599. bull_spare    equ    43    ;spare
  7600. bull_paddr    equ    44    ;players structure address
  7601. bull_lazx    equ    48    ;lazer lethal zonex start
  7602. bull_lazx2     equ    50    ;lazer lethal zonex end
  7603. bull_lazy    equ    52    ;lazer lethal zoney start
  7604. bull_lazy2    equ    54    ;lazer lethal zoney end
  7605. bull_Lrest    equ    56    ;off set of screen for Lazer restore
  7606. bull_LBnk    equ    60    ;what restore bank do i use!
  7607. bull_mapx    equ    61    ;position on mapx *NOT USED* except for some... always setup for stability!
  7608. bull_mapy    equ    62    ;position on mapy *NOT USED*
  7609.  
  7610. ;bull_lazx
  7611. ;this stores the lethal X,Y of the lazer beams.
  7612. ;anything in this area will be destoryed.
  7613. ;Word X Word Y
  7614. ;if X & Y = 0 then dead lazer!
  7615.  
  7616.     even
  7617.     cnop    0,4
  7618. bull
  7619. bullet_list    dcb.b    bullet_max*(bullet_nd-bullet),0
  7620. FRED    dcb.b    100,$ff
  7621. gun_list    dcb.b    gun_max*(bullet_nd-bullet),0
  7622. HARRY    dcb.b    100,$ff
  7623.  
  7624. PlayerGun    dc.b    0    ;set this flag when you do any player bullet rtns (i.e. grab/print/restore/move/collision etc)
  7625.  
  7626. DEAD    equ    0    ;No Blitting
  7627. DYING    equ    1    ;dying anim dont grab/blit just restore
  7628. OKAY    equ    2    ;okay
  7629. NEW    equ    3    ;New DONT Restore
  7630. HURT    equ    4    ;player hit by summink (go white)
  7631.  
  7632. titletext
  7633.     dc.b    "press fire",$0a
  7634.     dc.b    "  to start",0
  7635.     
  7636. inbaset    dc.b    162        ;start line of new cline TOp
  7637. inpost    dc.b    20        ;where do you want it? (20=middle) TOP
  7638. inbaseb    dc.b    162+20        ;start line of new cline BOT
  7639. inposb    dc.b    20        ;where do you want it? (20=middle) BOT
  7640. pftswait    dc.b    0        ;wait this long before restartin    
  7641.  
  7642.     even
  7643.     cnop    0,4
  7644. clinedummy    dc.l    0
  7645. scrline    dcb.b    yobtitnum,0
  7646. maxline    dcb.b    yobtitnum,0
  7647. sinepos    dcb.b    yobtitnum,0
  7648. gfkline    dcb.b    yobtitnum,0
  7649.  
  7650. OPTP1JOY    dc.b    JOYPORT1    ;port 1 please 
  7651. OPTP2JOY    dc.b    JOYPORT1    ;port 2 please ;changed to stop duff gfx
  7652. OPTP3JOY    dc.b    JOYPORT1    ;port 1 please
  7653. OPTP4JOY    dc.b    JOYPORT2    ;port 2 please
  7654. OPTP5JOY    dc.b    JOYPORT1    ;port 1 please
  7655. OPTP6JOY    dc.b    JOYPORT2    ;port 2 please
  7656.  
  7657.     even
  7658. john
  7659.     lea    bads_list,a0
  7660.     move.b    bad_mapx(a0),d0
  7661.     move.b    bad_mapy(a0),d1
  7662.     lea    player1,a0
  7663.     move.b    play_mapx(a0),d0
  7664.     move.b    play_mapy(a0),d1
  7665.     rts
  7666.  
  7667.     cnop    0,4
  7668. spare    dc.l    0,0,0,0
  7669.  
  7670. ;    include    yoblev1.inc